| 06-18-2004, 06:33 PM | #1 |
i have a loop that goes something like this, Code:
function test takes nothing returns nothing
local integer i = 1
local integer array x //*this is going to be an item type array
set x[1] = 'dfff'
set x[2] = '4143'//* So on but with numbers that are actually correct until around x[7]
loop
exitwhen x[i] = 'null' //*this seems to exit right away even though x[1] isn't null
set i = i + 1
endloop
endfunctionany idea why this might happen? i just want the loop to stop when the variable is no longer defined |
| 06-18-2004, 09:03 PM | #2 |
What exactly is the problem? |
| 06-18-2004, 09:37 PM | #3 |
'null' may be too big of a value and it fucks the int limit. Anyway to check if the itemid is nothing just check if it equals zero like worldedit does. Your function is infinite limiting as no value equals to 'null'. Also you can't compare unitialized data as that too causes the thread to crash. |
| 06-19-2004, 05:34 PM | #4 |
ok so i guess i have to figure out something else =( |
| 06-20-2004, 03:48 PM | #5 |
First, replace "'null'" with 0. Then, after defining ALL you unit types into the array, set the last (after all your other elements) element to 0. Then it should work. ~Cubasis |
| 06-20-2004, 10:21 PM | #6 |
An integer cant be set to null, so I'm surprised it isnt giving a compile error with the invalid comparison. Cubasis is correct, null for an integer or real should correspond to 0, and you shouldn't use an int or float variable == null because it wont ever evaluate properly. |
| 06-20-2004, 10:53 PM | #7 |
hes not setting it to null hes setting it 'null' and I already said that as the first reply in the thread... |
| 06-20-2004, 10:58 PM | #8 |
weaaddar, I noticed that, but he never set the end-element to 'null' in the beginning, so I just suggested a more typical solution, than setting the end-element to 'null'. :P ~Cubasis |
| 06-21-2004, 08:26 PM | #9 |
function test takes nothing returns nothing local integer i = 1 local integer array x set x[1] = 'hfoo' //... set x[8] = $DEAD loop exitwhen x[i] == $DEAD set i = i + 1 endloop endfunction |
