summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/lmathlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lua/lmathlib.c')
-rw-r--r--apps/plugins/lua/lmathlib.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/apps/plugins/lua/lmathlib.c b/apps/plugins/lua/lmathlib.c
index 99a104050c..56c79afced 100644
--- a/apps/plugins/lua/lmathlib.c
+++ b/apps/plugins/lua/lmathlib.c
@@ -82,19 +82,17 @@ static int math_atan2 (lua_State *L) {
82 lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); 82 lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
83 return 1; 83 return 1;
84} 84}
85#endif
86 85
87static int math_ceil (lua_State *L) { 86static int math_ceil (lua_State *L) {
88 /* Doesn't change anything in fixed point arithmetic */ 87 lua_pushnumber(L, ceil(luaL_checknumber(L, 1)));
89 lua_pushnumber(L, luaL_checknumber(L, 1));
90 return 1; 88 return 1;
91} 89}
92 90
93static int math_floor (lua_State *L) { 91static int math_floor (lua_State *L) {
94 /* Doesn't change anything in fixed point arithmetic */ 92 lua_pushnumber(L, floor(luaL_checknumber(L, 1)));
95 lua_pushnumber(L, luaL_checknumber(L, 1));
96 return 1; 93 return 1;
97} 94}
95#endif
98 96
99static int math_fmod (lua_State *L) { 97static int math_fmod (lua_State *L) {
100 /* Was: lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); */ 98 /* Was: lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); */
@@ -220,6 +218,11 @@ static int math_randomseed (lua_State *L) {
220 return 0; 218 return 0;
221} 219}
222 220
221static int math_ident (lua_State *L) { /* ROCKLUA ADDED */
222 /* Ceil & floor Doesn't change anything in fixed point arithmetic */
223 lua_pushnumber(L, luaL_checknumber(L, 1));
224 return 1;
225}
223 226
224static const luaL_Reg mathlib[] = { 227static const luaL_Reg mathlib[] = {
225 {"abs", math_abs}, 228 {"abs", math_abs},
@@ -228,17 +231,15 @@ static const luaL_Reg mathlib[] = {
228 {"asin", math_asin}, 231 {"asin", math_asin},
229 {"atan2", math_atan2}, 232 {"atan2", math_atan2},
230 {"atan", math_atan}, 233 {"atan", math_atan},
231#endif
232 {"ceil", math_ceil}, 234 {"ceil", math_ceil},
233#if 0
234 {"cosh", math_cosh}, 235 {"cosh", math_cosh},
235 {"cos", math_cos}, 236 {"cos", math_cos},
236#endif 237#endif
237 {"deg", math_deg}, 238 {"deg", math_deg},
238#if 0 239#if 0
239 {"exp", math_exp}, 240 {"exp", math_exp},
240#endif
241 {"floor", math_floor}, 241 {"floor", math_floor},
242#endif
242 {"fmod", math_fmod}, 243 {"fmod", math_fmod},
243#if 0 244#if 0
244 {"frexp", math_frexp}, 245 {"frexp", math_frexp},
@@ -262,6 +263,8 @@ static const luaL_Reg mathlib[] = {
262 {"tanh", math_tanh}, 263 {"tanh", math_tanh},
263 {"tan", math_tan}, 264 {"tan", math_tan},
264#endif 265#endif
266 {"ceil", math_ident},
267 {"floor", math_ident},
265 {NULL, NULL} 268 {NULL, NULL}
266}; 269};
267 270