Variable must be a type

Übersicht BlitzBasic Beginners-Corner

Neue Antwort erstellen

 

mavi

Betreff: Variable must be a type

BeitragDo, Mai 07, 2009 14:03
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo ich komm nicht weiter, bei mir sthet immer "Variable must be a Type"

Code: [AUSKLAPPEN]
For i = 0 To 19
   DrawImage slot_image, slot1\slot_x,slot1\slot_y
   slot_x = slot_x + 58
   slot_y = slot_y + 50
Next


Code: [AUSKLAPPEN]
For i = 0 To 19
   slot1.slot = New Slot
      slot1\full = 0
      slot1\slot_x = 52
      slot1\slot_y = 66
Next


Code: [AUSKLAPPEN]
Type slot
 Field slot_x
 Field slot_y
 Field full
End Type



Bei mir kommt immer die Fehlermeldung "Variable must be a type"
 

aletes

BeitragDo, Mai 07, 2009 14:09
Antworten mit Zitat
Benutzer-Profile anzeigen
?? was ist das??
ich glaube du wolltest auf einen thread antworten, hast aber ausversehen einen neuen thread erstellt Wink
 

da_poller

BeitragDo, Mai 07, 2009 14:09
Antworten mit Zitat
Benutzer-Profile anzeigen
BlitzBasic: [AUSKLAPPEN]
For slot1.slot = Each Slot
DrawImage slot_image, slot1\slot_x,slot1\slot_y
slot_x = slot_x + 58
slot_y = slot_y + 50
Next

so sollts richtig heisen..

NightPhoenix

BeitragDo, Mai 07, 2009 14:10
Antworten mit Zitat
Benutzer-Profile anzeigen
Code: [AUSKLAPPEN]
slot_image=CreateImage(100,100)

Type Slot
   Field slot_x
   Field slot_y
   Field full
End Type



For i=0 To 19
   slot1.slot = New Slot
      slot1\full = 0
      slot1\slot_x = 52
      slot1\slot_y = 66
Next


For i = 0 To 19
   DrawImage slot_image, slot1\slot_x,slot1\slot_y
   slot_x = slot_x + 58
   slot_y = slot_y + 50
Next


Also wenn du den Code zu geschrieben hast wie deine Reihenfolge oben kann das garnicht funktionieren. Du würdest auf einen Typ zugreifen welcher noch garnicht erstellt wurde Wink
Du setzt dich ja auch nicht auf die Straße und tust so als ob du einen lenker halten würdest wenn du erst morgen das Auto kaufst Smile



*edit*
Hä?? Wurde die Frage editiert?
Irgendwie hat er seine Frage selbst zu beantworten verwsucht, zumindest sieht es so aus Shocked

*edit2*
Ah D2006 alles klar Smile
  • Zuletzt bearbeitet von NightPhoenix am Do, Mai 07, 2009 14:15, insgesamt 5-mal bearbeitet

D2006

Administrator

BeitragDo, Mai 07, 2009 14:12
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich bitte um Verzeihung!

Ich wollte mit Zitat antworten und hab aus Versehen auf Editieren geklickt, ohne es zu merken. Soeben habe ich den ursprünglichen Beitrag wiederhergestellt. Meine Antwort ist hinfällig, das sie mit da_pollers identisch ist.
Intel Core i5 2500 | 16 GB DDR3 RAM dualchannel | ATI Radeon HD6870 (1024 MB RAM) | Windows 7 Home Premium
Intel Core 2 Duo 2.4 GHz | 2 GB DDR3 RAM dualchannel | Nvidia GeForce 9400M (256 MB shared RAM) | Mac OS X Snow Leopard
Intel Pentium Dual-Core 2.4 GHz | 3 GB DDR2 RAM dualchannel | ATI Radeon HD3850 (1024 MB RAM) | Windows 7 Home Premium
Chaos Interactive :: GoBang :: BB-Poker :: ChaosBreaker :: Hexagon :: ChaosRacer 2
 

mavi

BeitragDo, Mai 07, 2009 14:34
Antworten mit Zitat
Benutzer-Profile anzeigen
Ihr missversteht mich kann auch daran liegen, dass ich mich falsch ausdrücke, also

Ich habe meine "MAIN" Datei Dort habe ich folgenes festgelegt:
Code: [AUSKLAPPEN]
Graphics 640,480,16,0
SetBuffer BackBuffer()

;// Images laden //
Global   windowchar   =   LoadImage("charfenster.bmp")
Global  windowinv   =   LoadImage("inventar.bmp")
Global   interface   =    LoadImage("interface.bmp")
Global   gras      =   LoadImage("gras.bmp")
Global   wasser      =   LoadImage("wasser.bmp")
Global   slot_image   =   LoadImage("slot.bmp")
Global   hero      =   LoadAnimImage("hero.bmp",24,32,0,12)
MaskImage   hero,   255,0,255
MaskImage    interface, 255,255,255



;//Varibalen//
Global    timer      =   CreateTimer(25)
Global   herodir      =   0
Global   heroframe   =   0
Global   unten      =   6
Global   oben      =   0
Global   rechts      =   3
Global   links      =   9
Global    move      =   0
Global  charfenster
Global  inventar
Global   talent
Global   sx
Global   sy
Global   x
Global   y
Global   karte
Global   anim_time
Global    keyboard   = 1
Global    cx =52
Global    cy =66

;{ Lebensanzeige; Manaanzeige; Erfahrungsanzeige }
Global l3#
Global l2#
Global l1#
Global m3#
Global m2#
Global m1#
Global e3#
Global e2#
Global e1#
Global pl#
Global pm#
Global plm#
Global pmm#
Global ep#
Global lvlxp#

Include "player.bb"


;//MAP//

Dim map(31,23)
karte   =   OpenFile("map.dat")

For   y = 0 To 23
   For x = 0 To 31
      map(x,y) = ReadByte(karte)
   Next
Next


For i = 0 To 19
   slot1.slot = New Slot
      slot1\full = 0
      slot1\slot_x = 52
      slot1\slot_y = 66
Next


anim_time = MilliSecs()

;//HAUPTSCHLEIFE//

Repeat
drawmap()
move   =   0
movement()
anim()
level()

;Drawhero
DrawImage hero,px-sx,py-sy,heroframe + herodir

interface()
control()

WaitTimer(timer)
Flip
Cls
Until KeyHit(1):End
CloseFile karte


;//INCLUDE//
Include "func2.bb"
Include "interface.bb"
Include "control.bb"
Include "type.bb"


dann habe ich eine "Type.bb":
Code: [AUSKLAPPEN]
;//TYPE.BB

Type slot
 Field slot_x
 Field slot_y
 Field full
End Type


und noch eine "Interface.bb" mit der function interface():
Code: [AUSKLAPPEN]
Function interface()
;//GUI - Leiste //
DrawImage interface, 160,430

pl# = Float#(player_life)
plm# = Float#(player_life_max)
pm# = Float#(player_mana)
pmm# = Float#(player_mana_max)
ep# = Float#(xp)
lvlxp# = Float#(levelxp)

l3# = (pl#/plm#)*100
l2# = 100/100
l1# = l3#*l2#

m3# = (pm#/pmm#)*100
m2# = 100/100
m1# = m2#*m3#

e3# = (ep#/lvlxp#)*100
e2# = 100/100
e1# = e2#*e3#


If player_life > player_life_max Then
player_life = player_life_max
EndIf

If player_mana > player_mana_max Then
player_mana = player_mana_max
EndIf

;{ Lebensanzeige
Color 255,0,0
Rect 60,10, l1#,15,1   ;Größe durch Variable ersetzen
Color 255,255,254
Rect 60,10, 100,15,0   ;Rahmen
;}

;{ Manaanzeige
Color 0,0,255
Rect 230,10, m1#,15,1
Color 255,255,254
Rect 230,10, 100,15,0
;}

;{ EPanzeige
Color 0,255,0
Rect 400, 10, e1#,15,1
Color 255,255,254
Rect 400, 10, 100,15,0
;}

;{ Text
Text 10, 10, "Leben"
Text 180, 10, "Mana"
Text 370, 10, "EP"






































;//Charakterfenster//

If KeyHit(46) Then
charfenster = Not charfenster
keyboard = 1
EndIf

If charfenster Then
keyboard = 0
Color 0,128,255
DrawImage windowchar,50,50
DrawImage slot_image,60,66
DrawImage slot_image,60,118
DrawImage slot_image,60,170
DrawImage slot_image,60,222
DrawImage slot_image,60,274
DrawImage slot_image,125,274
DrawImage slot_image,177,274

Color 255,255,255
Text 120,70,    "Name:      " + name$
Text 120,85,   "Klasse:    " + klasse$
Text 120,100,   "Level:     " + level
Text 120,130,   "Leben:     " + player_life + "/" + player_life_max
Text 120,145,   "Mana:      " + player_mana + "/" + player_mana_max
Text 120,160,   "EP:        " + xp
Text 120,185,   "Stärke     " + "   " + strength
Text 120,200,   "Beweglichk." + "   " + agility
Text 120,215,   "Intelligenz" + "   " + intelligenz
Text 120,230,   "Ausdauer   " + "   " + stamina
Text 120,245,   "Rüstung    " + "   " + armor
EndIf







;//Inventar//
If KeyHit(48) Then
inventar = Not inventar
keyboard =1
EndIf

If inventar Then
keyboard = 0


;{Reihe 1
DrawImage windowinv, 50,50
;DrawImage slot, 52, 66
;DrawImage slot, 110, 66
;DrawImage slot, 168, 66
;DrawImage slot, 226, 66
;{Reihe 2
;DrawImage slot, 52, 116
;DrawImage slot, 110,116
;DrawImage slot, 168,116
;DrawImage slot, 226,116

;{Reihe 3
;DrawImage slot, 52,  166
;DrawImage slot, 110, 166
;DrawImage slot, 168, 166
;DrawImage slot, 226, 166

;{Reihe 4
;DrawImage slot, 52, 216
;DrawImage slot, 110, 216
;DrawImage slot, 168, 216
;DrawImage slot, 226, 216

;{Reihe 5
;DrawImage slot, 52, 266
;DrawImage slot, 110,266
;DrawImage slot, 168,266
;DrawImage slot, 226,266

For i = 0 To 19
   DrawImage slot_image, slot1\slot_x,slot1\slot_y
   slot_x = slot_x + 58
   slot_y = slot_y + 50
Next
EndIf




;{STEUERUNG Coursor


If keyboard = 0 And inventar Then

If KeyHit(200) Then ;nach oben
cy = cy - 50
EndIf
If KeyHit(208) Then ;nach unten
cy = cy + 50
EndIf
If KeyHit(203) Then ;nach links
cx = cx - 58
EndIf
If KeyHit(205) Then ;nach rechts
cx = cx +58
EndIf

If cx > 226 Then
cx = 226
EndIf
If cx < 52 Then
cx = 52
EndIf

If cy > 266 Then
cy = 266
EndIf

If cy < 66 Then
cy = 66
EndIf

Rect cx,cy, 48,48,0
EndIf





End Function


das wären alle dateien ich möchte wenn Very Happy wenn ich B drücke das dann eine grafik gezeichnet wird. genauso wie es da in der schleife steht. aber das funktioniert nicht Very Happy weil dann kommt "Variable...."

Smily

BeitragDo, Mai 07, 2009 14:37
Antworten mit Zitat
Benutzer-Profile anzeigen
Ja, weil, wie bereits geschrieben der Teil vollkommener schwachsin ist:

Code: [AUSKLAPPEN]

For i = 0 To 19
   DrawImage slot_image, slot1\slot_x,slot1\slot_y
   slot_x = slot_x + 58
   slot_y = slot_y + 50
Next
Lesestoff:
gegen Softwarepatente | Netzzensur | brain.exe | Unabhängigkeitserklärung des Internets

"Wir müssen die Rechte der Andersdenkenden selbst dann beachten, wenn sie Idioten oder schädlich sind. Wir müssen aufpassen. Wachsamkeit ist der Preis der Freiheit --- Keine Zensur!"
stummi.org
 

mavi

BeitragDo, Mai 07, 2009 14:41
Antworten mit Zitat
Benutzer-Profile anzeigen
smily, ich kann dir nicht ganz folgen, meinst du was ich geschrieben habe ist schwachsinn?

NightPhoenix

BeitragDo, Mai 07, 2009 14:53
Antworten mit Zitat
Benutzer-Profile anzeigen
Du schreibst erst:

Code: [AUSKLAPPEN]
For i = 0 To 19
   slot1.slot = New Slot
      slot1\full = 0
      slot1\slot_x = 52
      slot1\slot_y = 66
Next


und danach:
Code: [AUSKLAPPEN]
;//INCLUDE//
Include "func2.bb"
Include "interface.bb"
Include "control.bb"
Include "type.bb"


mit dem Inhalt:
Code: [AUSKLAPPEN]
Type slot
 Field slot_x
 Field slot_y
 Field full
End Type


sprich du erstellst erst einen Typ Eintrag und dann erst den Type...

das ist wie etwas auf einen Tisch zu schreiben und dann erst das Papier hinzulegen.

also mache alle Includes am Anfang des Programms

MfG. NightPhoenix



*edit*
@Smily:
Das ist garnicht mal so schlimm, solange er die Anzahl der Typeeinträge bei 20 belässt.
 

mavi

BeitragDo, Mai 07, 2009 14:57
Antworten mit Zitat
Benutzer-Profile anzeigen
hallo, habe ich gemacht der fehler mit der variable kommt bei

Code: [AUSKLAPPEN]
DrawImage slot_image, slot1\slot_x,slot1\slot_y



den ganzen quatsch hab ich schon was ihr da erzählt^^ Very Happy ich habe die reihenfolge schon beachtet Razz

es liegt an dem drawimage ich weiß nich woran da?!

Xeres

Moderator

BeitragDo, Mai 07, 2009 15:02
Antworten mit Zitat
Benutzer-Profile anzeigen
Füge in der Zeile davor mal ein stop ein und schau dir an welchen wert slot1 beinhaltet.

@NightPhoenix:
Na, Smily behält recht: slot1 bleibt immer das gleiche Objekt und die Position die da berechnet wird, ist nicht die des Types...
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus
T
HERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld)
 

mavi

BeitragDo, Mai 07, 2009 15:07
Antworten mit Zitat
Benutzer-Profile anzeigen
die positionen die da errechnet werden sollen Very Happy sind die position für die bilder Very Happy

die ausgabe von slot1 ist 0 :O

Xeres

Moderator

BeitragDo, Mai 07, 2009 15:13
Antworten mit Zitat
Benutzer-Profile anzeigen
mavi hat Folgendes geschrieben:
die positionen die da errechnet werden sollen Very Happy sind die position für die bilder Very Happy
...die du nicht verwendest.
slot_x <> slot1\slot_x Exclamation
mavi hat Folgendes geschrieben:
die ausgabe von slot1 ist 0 :O
Null oder 0 ? Slot1 enthält kein objekt wenn z.B. die letzte For...each schleife durchlaufen wurde...

So...
Code: [AUSKLAPPEN]
For slot1.slot = Each Slot
DrawImage slot_image, slot1\slot_x,slot1\slot_y
Next


oder so...
Code: [AUSKLAPPEN]
For i = 0 To 19
DrawImage slot_image, slot_x, slot_y
slot_x = slot_x + 58
slot_y = slot_y + 50
Next


könnt's schon eher klappen.

Edit: Verbessert... jetzt schreib ich auch schon Nonsens Oo
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus
T
HERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld)
  • Zuletzt bearbeitet von Xeres am Do, Mai 07, 2009 15:18, insgesamt 2-mal bearbeitet

Xaymar

ehemals "Cgamer"

BeitragDo, Mai 07, 2009 15:16
Antworten mit Zitat
Benutzer-Profile anzeigen
slot1 wird gar nicht gesetzt... zumindest finde ich kein slot1 = ...

Code: [AUSKLAPPEN]
for Slot1.Slot = each Slot
    Drawimage slot_image, slot1\slot_x, slot1\slot_y
...
next


Und "Schwachsinn" war richtig^^ Um Types zu benutzen must du einzelne einträge anvisieren(First, Before, After, Object, Each)

Ich hoffe ich liege richtig. Bin grade auffer arbeit und habe nichts zu tun und bin deshalb nur eben rübergeflogen^^

[Edit zu langsam
Warbseite

Smily

BeitragDo, Mai 07, 2009 15:31
Antworten mit Zitat
Benutzer-Profile anzeigen
Xeres: Deine zweite Methode ist nonsens. Du zeichnest ein bild 19 mal übereinander


Das mit each wurde schon in der 2. Antwort erwähnt, allerdings vom Threadersteller gekonnt ignoriert

Achja, meines wissens nach ist es dem compiler egal, wann ein type im code definiert wird. Er macht das immer am Anfang

grüße,
Smily
Lesestoff:
gegen Softwarepatente | Netzzensur | brain.exe | Unabhängigkeitserklärung des Internets

"Wir müssen die Rechte der Andersdenkenden selbst dann beachten, wenn sie Idioten oder schädlich sind. Wir müssen aufpassen. Wachsamkeit ist der Preis der Freiheit --- Keine Zensur!"
stummi.org
 

mavi

BeitragDo, Mai 07, 2009 15:34
Antworten mit Zitat
Benutzer-Profile anzeigen
danke smily Very Happy du hattest recht gekonnt ignoriert Very Happy ich habs aber ge schafft Very Happy dank xeres Very Happy

danke an alle Very Happy <.< ich idiot

Neue Antwort erstellen


Übersicht BlitzBasic Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group