diff options
author | madmaxoft <github@xoft.cz> | 2014-01-19 23:49:19 +0100 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-01-19 23:49:19 +0100 |
commit | 41618bf242e66744431a1d28e0409f543fb240e4 (patch) | |
tree | 0b5cfe41e67468f495c2c01707d7379f3a241bb5 /src/Bindings/ManualBindings.cpp | |
parent | cLuaState can now check function params. (diff) | |
download | cuberite-41618bf242e66744431a1d28e0409f543fb240e4.tar cuberite-41618bf242e66744431a1d28e0409f543fb240e4.tar.gz cuberite-41618bf242e66744431a1d28e0409f543fb240e4.tar.bz2 cuberite-41618bf242e66744431a1d28e0409f543fb240e4.tar.lz cuberite-41618bf242e66744431a1d28e0409f543fb240e4.tar.xz cuberite-41618bf242e66744431a1d28e0409f543fb240e4.tar.zst cuberite-41618bf242e66744431a1d28e0409f543fb240e4.zip |
Diffstat (limited to 'src/Bindings/ManualBindings.cpp')
-rw-r--r-- | src/Bindings/ManualBindings.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 3ebe7b294..2206dd371 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -986,11 +986,10 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S) class cLuaScheduledWorldTask : - public cWorld::cScheduledTask + public cWorld::cTask { public: - cLuaScheduledWorldTask(cPluginLua & a_Plugin, int a_FnRef, int a_Ticks) : - cScheduledTask(a_Ticks), + cLuaScheduledWorldTask(cPluginLua & a_Plugin, int a_FnRef) : m_Plugin(a_Plugin), m_FnRef(a_FnRef) { @@ -1025,14 +1024,19 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S) } // Retrieve the args: - cWorld * self = (cWorld *)tolua_tousertype(tolua_S, 1, 0); - if (self == NULL) + cLuaState L(tolua_S); + if ( + !L.CheckParamUserType(1, "cWorld") || + !L.CheckParamNumber (2) || + !L.CheckParamFunction(3) + ) { - return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance"); + return 0; } - if (!lua_isfunction(tolua_S, 2)) + cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, NULL); + if (World == NULL) { - return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a function for parameter #1"); + return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance"); } // Create a reference to the function: @@ -1042,9 +1046,9 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S) return lua_do_error(tolua_S, "Error in function call '#funcname#': Could not get function reference of parameter #1"); } - int Ticks = (int) tolua_tonumber (tolua_S, 3, 0); + int DelayTicks = (int)tolua_tonumber(tolua_S, 2, 0); - self->ScheduleTask(new cLuaScheduledWorldTask(*Plugin, FnRef, Ticks)); + World->ScheduleTask(DelayTicks, new cLuaScheduledWorldTask(*Plugin, FnRef)); return 0; } |