TannerRogalsky / love.js

LÖVE ported to the web using Emscripten
MIT License
491 stars 52 forks source link

bad argument #2 to 'random' (interval is empty) #31

Closed spectrenoir06 closed 8 years ago

spectrenoir06 commented 8 years ago

Hello i have encounter a strange error with math.random(100, -100)

Error

capture d ecran de 2016-03-12 20 42 45

Weapon.lua

capture d ecran de 2016-03-12 20 46 35

TannerRogalsky commented 8 years ago

Your code throws an error in Lua. You probably want to reverse the arguments to math.random if you're trying to get a random number between -100 and 100. You will see similar errors when running your game using the native love executable.

http://www.lua.org/manual/5.1/manual.html#pdf-math.random

spectrenoir06 commented 8 years ago

Thank's for the short response

I have understand the probleme i'ts because love.js use standart Lua and Löve use luaJIT

Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> print(math.random(100,-100))
stdin:1: bad argument #2 to 'random' (interval is empty)
stack traceback:
    [C]: in function 'random'
    stdin:1: in main chunk
    [C]: in ?
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/
> print(math.random(100,-100))
-59
TannerRogalsky commented 8 years ago

@spectrenoir06 Ah, very true. That's pretty weird. Thanks for figuring that out!