aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lmathlib.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lmathlib.js b/src/lmathlib.js
index b10f7bf..32893a6 100644
--- a/src/lmathlib.js
+++ b/src/lmathlib.js
@@ -80,7 +80,9 @@ const math_acos = function(L) {
};
const math_atan = function(L) {
- lua.lua_pushnumber(L, Math.atan(lauxlib.luaL_checknumber(L, 1)));
+ let y = lauxlib.luaL_checknumber(L, 1);
+ let x = lauxlib.luaL_optnumber(L, 2, 1);
+ lua.lua_pushnumber(L, Math.atan2(y, x));
return 1;
};