Closed cdsimmons closed 1 year ago
I had a response on Jaseowns discord, these are workarounds...
createlist TestList
clearlist TestList
@pushlist TestList 10
@pushlist TestList 80
@pushlist TestList 80000
overhead 'result...'
foreach val in TestList
if 5000 < val
overhead 'y'
else
overhead 'n'
endif
endfor
This passes the expected output.
If we want to compare var against var, we can do this...
@setvar! testVarSmall 80
@setvar! testVarLarge 400
createlist TestList
clearlist TestList
pushlist TestList testVarSmall
overhead 'result1...'
if poplist TestList front < testVarLarge
overhead 'y'
else
overhead 'n'
endif
Razor compares two variables as strings, not as int values, so it's doing a string compare to to see if "2" > "16", not 2 > 16.
This isn't a bug, the Razor scripting engine wasn't just designed for that type of operation (though I can see how it could cause confusion).
I might explore a future update with this functionality.
Using ClassicUO, for Outlands.
See this script...
Expected output
Actual output
For some reason Razor scripts think that 80 is greater than 5000. It seems like numbers are stored as floats. This results in an incorrect clause like 8.0 > 5.0.
This issue seems to affect numbers saved in lists, and numbers saved as vars.