Page 1 of 1

test if a bagslot is empty

Posted: Wed Mar 03, 2010 10:45 am
by Thor
Hello together,

is where anybody able to tell me a way to test if a bagslot is empty? I tried it thies way:

if ( inventory.bagslot[59] not null ) then ....

but it doesn't work.

Thx for help

Re: test if a bagslot is empty

Posted: Mon Mar 08, 2010 1:15 am
by rock5
That's not proper lua code. Assuming inventory.bagslot[59] is correct(which I haven't checked) try;

if not (inventory.bagslot[59] == null ) then ....

or

if ( inventory.bagslot[59] ~= null ) then ....

or just

if inventory.bagslot[59] then ....

because if used in this way, a nul value is taken to be false and any other value is taken to be true. Read it as;
'if inventory.bagslot[59] has a value then ...'