-
Notifications
You must be signed in to change notification settings - Fork 485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LuaForWindows_v5.1.4-46 #131
Comments
in last version is wrong too |
That's a lua problem. -- you only get 200
count = 0
while count < 100 do
number = math.random(200, 300)
print(number)
if number == 200 then
break
end
count = count + 1
end -- works properly
math.randomseed(os.time())
count = 0
while count < 100 do
number = math.random(200, 300)
print(number)
if number == 200 then
break
end
count = count + 1
end REF: |
This issue is more than a randomseed issue. print(os.time()) -- this prints a different time each time.
math.randomseed(os.time())
for i = 1, 5 do
print(math.random(1, 100))
end outputs this, notice the first number on every test. Each test was done several seconds apart from each other to ensure os.time() returned a new number.
Running the same code on several online compilers this issue doesn't happen. Those compilers use Lua 5.4, one allowed me to use down to lua 5.3,2 and the issue was not a thing with that one either. It's possible this issue existed in Lua 5.1 which this project uses. |
math.random() is wrong
for example
math.random(200)
is only 1
or
math.random(200,300)
is only 200
The text was updated successfully, but these errors were encountered: