Type problems
Blitz3D Forums/Blitz3D Beginners Area/Type problems
| ||
Gfrr - I am beginning to hate BB. OK, here is my problem. I have a working chat program. I have TRIED to add in a map program (a simple 2D scoller) behind it. Stand alone it works fine. As soon as I combine it then it just doesnt want to know. I get a message, even BEFORE it runs, that a 'variable should be a type'. It IS a type, the map was created using this type as a bank. yet map/ifsetx is not valid despite having been declared in the Types.bb include that I use. Any ideas why in the main code of my program that this map type is no longer valid ? Thanks in advance. Chris. |
| ||
its hard to help without seeing the code could you post it? also check for typo's MikeT |
| ||
Sounds like you have a duplicate name! |
| ||
it would be hard to post as its a BIG bit of code with lots of includes, but i willl see what I can do. I wish it was a duplicate, but alas it isnt. :( Type isnt likely as I cut and paste from the demo program i had setup that was working fine !! |
| ||
OK here are the snippets of the code i am using - its from the simplescroller Type SimpleScroller ;private fields Field buffer Field dividerx Field dividery Field tilegraphics Field mapbank Field tilesizebits Field viewportx Field viewporty Field viewportw Field viewporth Field tilesize Field offsetx Field offsety End Type creating it with ;Create a SimpleScroller instance ss1.SimpleScroller = New SimpleScroller This line gives the error stating ss1\offsetx basically saying Variable must be a type If (ss1\offsetx + ss1x < 0) All this happens before the program even runs!!!!! |
| ||
Your program must be compiling/executing If (ss1\offsetx + ss1x < 0) before this ss1.SimpleScroller = New SimpleScroller |
| ||
surely if i type this then the program will not work as the data that was in ss1\offsetx will not be, for example 32 as it has just been created as a new instance. Also i tried a for each simplescroller but this also faield as there seemed to be no data in the ss1. Sooooo annoying, but i like the ideas. |
| ||
or this line:If (ss1\offsetx + ss1x < 0) ...is within a function, and ss1 is not declared as Global (or passed into the function) |
| ||
correct amundo Mr Soja! |
| ||
Hmmm - you can only craete GLOBALS in the main blitz program and not the includes!! |
| ||
Hmmmm? You can have globals in the include as long as you don't try to use them before the include statement. For example if stuff.bb contains the global Myvar then you can't Myvar=10 include "stuff.bb" but you can include "stuff.bb" Myvar=10 |
| ||
I am haivng a similar problem with my 3d demo. I am having trouble referring to another type. I get the 'variable should be a type' error too. This example below from 'update enemy' function if entitydistance( e\model1, p\model)>3 then PointEntity Blahhhh.. using this I get that error 'variable should be a type' if I take this out of the function and put it the main loop it works fine If I say .. if entitydistance( e\model1, box1)>3 this gives me no error , so its the p\model which is giving the probs. but that is the correct naming convention for that type , it works in other functions fine. |
| ||
do you have 'p' defined as another type (i.e. Int) in that function? |
| ||
errm I don't think so p is from the player type, e is the enemy type. I am using the the same mesh for both types , using copy entity. perhaps this is causing problems? i am trying to call the p\model type from within the enemy function. It works fine if I put it in the main loop, but for the sake of tidiness I want to use an update enemy function. I would post the code but its all over the place right now |
| ||
kindof sorted it out, not quite sure what i did to fix it, but my 'update enemy' function works now.I stil cant seem to refer to p/model within that type, so i created another pivot for p.player and refer to that instead. gaah easy to get confused with tpyes |