PDA

View Full Version : Game->LItem[];



Joe123
02-07-2008, 12:42 PM
int LItems[]
* The level items of level i currently under the posession of the player,
* where i is the index used to access this array. Each element of this
* array consists of flags ORed (|) together; use the LI_ constants in
* std.zh to set or compare these values.

How do I use this?

Edit:
Right, so it uses binary.
And to check whether Link has the compass, I do something like this:

int cmp = 0100b;
int curitems = Game->LItems[lvnum];
int chk = cmp & curitems;
if(chk == 0100b){
Correct?

However, apparently the Boss Key item is '16' in std.zh.
How am I supposed to express 16 in a 4-bit byte?
This is illogical.

DarkDragon
02-07-2008, 07:10 PM
Use more bits? Or use the LI_ constants in std.zh.

You can also just do


if(Game->LItems[lvnum] & LI_WHATEVER != 0)
{
//stuff
}

Joe123
02-07-2008, 07:18 PM
Can I just add more bits on if I want to?
I thought the size of the byte was standard and you have to use one of that size?

And that makes sense now I think about it, thankyou.

DarkDragon
02-07-2008, 07:23 PM
In C a byte is 8 bits, but the ZScript int is much bigger. (64 bits I believe, but don't quote me on that. Plenty enough to hold 16 = 10000b, is the point.)

Joe123
02-07-2008, 07:25 PM
Oh, so I can just stick extra bits on then.
Thanks, I thought I couldn't do that.

Well, not that I'll probably use it much again, but still.