luaforwindows icon indicating copy to clipboard operation
luaforwindows copied to clipboard

LuaForWindows_v5.1.4-46

Open mahdi-hajian opened this issue 4 years ago • 2 comments

math.random() is wrong

for example math.random(200) is only 1 or math.random(200,300) is only 200

mahdi-hajian avatar Dec 11 '20 15:12 mahdi-hajian

in last version is wrong too Lua for Windows v5.1.5-52 Released

mahdi-hajian avatar Dec 11 '20 15:12 mahdi-hajian

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: https://stackoverflow.com/questions/18199844/lua-math-random-not-working

TFWol avatar Mar 06 '23 21:03 TFWol