types

Blitz3D Forums/Blitz3D Beginners Area/types

Ben(t)(Posted 2007) [#1]
I get an error when this happens


If t#=6 Then
s.flash=New flash
s\entity=CopyEntity(flash)
s\alpha#=1
RotateEntity s\entity,EntityPitch(turret),EntityYaw(turret),EntityRoll(turret)
PositionEntity s\entity,EntityX(turret),EntityY(turret),EntityZ(turret)
MoveEntity s\entity,0,2.5,0
EndIf

If t#=7 Then
; right here
s.shot=New shot
; above line
s\entity=CopyEntity(shot)
s\scale#=.5
RotateEntity s\entity,EntityPitch(turret),EntityYaw(turret),EntityRoll(turret)
PositionEntity s\entity,EntityX(turret),EntityY(turret),EntityZ(turret)
MoveEntity s\entity,0,2.5,4
t#=0
EndIf


For s.flash=Each flash
EntityAlpha s\entity,s\alpha#
s\alpha#=s\alpha#-.1
If s\alpha# <=0 Then FreeEntity s\entity :Delete s
Next

For s.shot=Each shot
x=x+1
MoveEntity s\entity,0,0,.5
EntityAlpha s\entity,s\scale#
s\scale#=s\scale#+.05
If s\scale# >=3 Then FreeEntity s\entity :Delete s
Next


it says "variable type mismatch"
what does this mean?


Kev(Posted 2007) [#2]
flash is a type but your copying it as an entity using CopyEntity(flash) your also doing the same with shot.

kev


Stevie G(Posted 2007) [#3]
flash is a type but your copying it as an entity using CopyEntity(flash) your also doing the same with shot.



That's not the reason. In your loop you're re-using the variable s for different data types ( shot and flash ) which cannot be done inside the same function.

Try using f.flash for all the flash stuff - I'm pretty sure that will work.

Stevie


Kev(Posted 2007) [#4]
yes stevie is correct, i always use the first letter of the type when defining data types.

kev


Ben(t)(Posted 2007) [#5]
I had f.flash already but I was wondering why it did that in the first place.
so what exactly is the (s.)?