Compare commits

..

3 Commits

Author SHA1 Message Date
teoxoy be4f0fa982 fix "Unexpected negated condition" lint
1 year ago
teoxoy c2bc7cbe68 release v2.2.5
1 year ago
Keith af1cc0328f fix math.random
1 year ago

@ -1,6 +1,6 @@
{
"name": "lua-in-js",
"version": "2.2.4",
"version": "2.2.5",
"description": "A Lua to JS transpiler/runtime",
"keywords": [
"lua",

@ -143,8 +143,8 @@ function rad(x: LuaType): number {
function random(min?: LuaType, max?: LuaType): number {
if (min === undefined && max === undefined) return getRandom()
const firstArg = coerceArgToNumber(min, 'random', 1)
const MIN = max === undefined ? firstArg : 1
const MAX = max === undefined ? coerceArgToNumber(max, 'random', 2) : firstArg
const MIN = max === undefined ? 1 : firstArg
const MAX = max === undefined ? firstArg : coerceArgToNumber(max, 'random', 2)
if (MIN > MAX) throw new Error("bad argument #2 to 'random' (interval is empty)")
return Math.floor(getRandom() * (MAX - MIN + 1) + MIN)

Loading…
Cancel
Save