Open nioate opened 1 year ago
.. oh my god thanks for adding this issue. I spent a whole day checking why my script is not working. I figured out my dynamic number of the upper end of random can be 1. If its 1, I'll end up with
math.random(1,1)
which ends in a crash: "RangeError (RangeError (max): Must be positive and <= 2^32: Not in inclusive range 1..4294967296: 0) runLuaScript"
Is there any chance to fix this?
Added a pr to fix this :) https://github.com/arcticfox1919/LuaDardo/pull/29
As a workaround, I just added the following code to my lua script:
_old_random=math.random
math.random=function(a,b) return _old_random(0,b-a+1)+a end
The upper limit in math.random() with 1 or 2 arguments is wrong - it should be increased by 1. (Since the dart random number generator is used, random(1,10) will produce numbers from 1 to 9 while in lua the upper limit is included.)
And also the
ls.argCheck(low >= 0, 1, "interval too large");
shouldn't be there - lower limit can be <0.