Type problems

Blitz3D Forums/Blitz3D Beginners Area/Type problems

Zace(Posted 2004) [#1]
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.


MikeT(Posted 2004) [#2]
its hard to help without seeing the code could you post it?

also check for typo's

MikeT


Shambler(Posted 2004) [#3]
Sounds like you have a duplicate name!


Zace(Posted 2004) [#4]
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 !!


Zace(Posted 2004) [#5]
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!!!!!


Shambler(Posted 2004) [#6]
Your program must be compiling/executing

If (ss1\offsetx + ss1x < 0)

before this

ss1.SimpleScroller = New SimpleScroller


Zace(Posted 2004) [#7]
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.


soja(Posted 2004) [#8]
or this line:
If (ss1\offsetx + ss1x < 0) 

...is within a function, and ss1 is not declared as Global (or passed into the function)


Stevie G(Posted 2004) [#9]
correct amundo Mr Soja!


Zace(Posted 2004) [#10]
Hmmm - you can only craete GLOBALS in the main blitz program and not the includes!!


Shambler(Posted 2004) [#11]
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



Ruz(Posted 2004) [#12]
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.


soja(Posted 2004) [#13]
do you have 'p' defined as another type (i.e. Int) in that function?


Ruz(Posted 2004) [#14]
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


Ruz(Posted 2004) [#15]
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