Zed98 wrote:
- Code: Select all
moving = random_range(0,2)
dirswitch = random_range(0,2)
if dirswitch = 2
{
if dir = 0
{
dir = 1
exitrest = 1
}
if dir = 1
{
if exitrest = 0
dir = 0
}
exitrest = 1
exitrest = 0
}
There seems to be a potential source of error here. The random_range function returns a random real number between the two arguments, not only integers (so random_range(0,2) can return 1.287492, for example). Thus, the chance of (dirswitch == 0) is extremely unlikely. Also, the value it returns is inclusive for the lower argument but is NOT inclusive for the top argument, so (dirswitch == 2) is actually impossible. What you probably want is floor(random_range(0,3)); this returns an integer 0, 1, or 2. Also for the record, floor(random(3)) would return the same values as well.
I only scanned over the code briefly, so there may be more bugs in there, but there's a start.



