Duplicate Variable Name
Blitz3D Forums/Blitz3D Beginners Area/Duplicate Variable Name
| ||
hey guys. I'm new to Blitz3d and I ran ran into a problem. I tried to use the include function, and it just said duplicate variable name. here's the code. ; CreateCamera Example ; -------------------- Graphics3D 640,480 SetBuffer BackBuffer() AmbientLight 0,0,0 Include "CreateCamera2.bb" ; Create camera camera=CreateCamera() CameraClsColor camera,0,128,255 light=CreateLight() Global tree_sprite=LoadSprite( "media\Bigspark.bmp" ) HandleSprite tree_sprite,0,.1 ScaleSprite tree_sprite,50,50 PositionEntity tree_sprite,0,30,150 SpriteViewMode tree_sprite,3 cone=LoadAnimMesh("media/lego.b3d") PositionEntity cone,0,0,150 FlipMesh cone tex=LoadTexture("media/ffg.png") EntityTexture cone,tex ExtractAnimSeq cone,1,2 seq=1 Animate cone,1,.1,seq,10 cone2=LoadAnimMesh("media/sphere.b3d") PositionEntity cone2,0,300,150 tex2=LoadTexture("media/patch.png") EntityTexture cone2,tex2 ExtractAnimSeq cone2,1,2 seq2=1 Animate cone2,1,.1,seq2,10 While Not KeyDown( 1 ) UpdateWorld RenderWorld Flip Wend End can someone help? |
| ||
Could you post the code for "CreateCamera2.bb"? Or identify the line where the cursor ends up after the error when attempting to run the compiler in 'Debug' mode. The Duplicate Variable name, means you have declared a variable more than once. Very likely the issue would be due to a variable declared locally within a function with the same name as one elsewhere, or a Global variable whose name is later used trying to declare as Local. Since the variable names used above are: camera light tree_sprit tex tex2 cone cone2 seq and seq2 I would imagine you are re-using one of those names in "CreateCamera2.bb". Or perhaps Tree_sprite where it is defined again in this program. The use of "Include" is effectievly the same as if the CreateCamera2.bb code was inserted at the point of the Include command, however, on compilation, Constants, then Globals, then Functions are intrpreted, regardless of their position in the code. |
| ||
A Globally declared variable which is then explicitly declared as local in a function won't be an issue. As the only global you are declaring in the code above is "tree_sprite" I'm confident that this is your issue. All the other variables are assumed to be local so won't cause this error. |
| ||
Thanks. It's fixed now. |