summaryrefslogtreecommitdiffstats
path: root/source/ManualBindings.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-08-06 17:17:26 +0200
committermadmaxoft <github@xoft.cz>2013-08-06 17:17:26 +0200
commit4034136922a5b47450fa25c6be4bc35411a8d1ba (patch)
treef62f1bc0531f9cb1c1e5631121e70735bd55062a /source/ManualBindings.cpp
parentcLuaState now tracks the function name and number of args (diff)
downloadcuberite-4034136922a5b47450fa25c6be4bc35411a8d1ba.tar
cuberite-4034136922a5b47450fa25c6be4bc35411a8d1ba.tar.gz
cuberite-4034136922a5b47450fa25c6be4bc35411a8d1ba.tar.bz2
cuberite-4034136922a5b47450fa25c6be4bc35411a8d1ba.tar.lz
cuberite-4034136922a5b47450fa25c6be4bc35411a8d1ba.tar.xz
cuberite-4034136922a5b47450fa25c6be4bc35411a8d1ba.tar.zst
cuberite-4034136922a5b47450fa25c6be4bc35411a8d1ba.zip
Diffstat (limited to '')
-rw-r--r--source/ManualBindings.cpp31
1 files changed, 8 insertions, 23 deletions
diff --git a/source/ManualBindings.cpp b/source/ManualBindings.cpp
index 141335602..292b33726 100644
--- a/source/ManualBindings.cpp
+++ b/source/ManualBindings.cpp
@@ -25,13 +25,6 @@
-// fwd: LuaCommandBinder.cpp
-// bool cLuaState::ReportErrors(lua_State* lua, int status);
-
-
-
-
-
/****************************
* Better error reporting for Lua
**/
@@ -84,23 +77,14 @@ int lua_do_error(lua_State* L, const char * a_pFormat, ...)
* Lua bound functions with special return types
**/
-static int tolua_StringSplit(lua_State* tolua_S)
+static int tolua_StringSplit(lua_State * tolua_S)
{
- std::string str = ((std::string) tolua_tocppstring(tolua_S,1,0));
- std::string delim = ((std::string) tolua_tocppstring(tolua_S,2,0));
-
- AStringVector Split = StringSplit( str, delim );
+ cLuaState LuaState(tolua_S);
+ std::string str = (std::string)tolua_tocppstring(LuaState, 1, 0);
+ std::string delim = (std::string)tolua_tocppstring(LuaState, 2, 0);
- lua_createtable(tolua_S, Split.size(), 0);
- int newTable = lua_gettop(tolua_S);
- int index = 1;
- std::vector<std::string>::const_iterator iter = Split.begin();
- while(iter != Split.end()) {
- tolua_pushstring( tolua_S, (*iter).c_str() );
- lua_rawseti(tolua_S, newTable, index);
- ++iter;
- ++index;
- }
+ AStringVector Split = StringSplit(str, delim);
+ LuaState.PushStringVector(Split);
return 1;
}
@@ -158,7 +142,8 @@ cPlugin_NewLua * GetLuaPlugin(lua_State * L)
lua_getglobal(L, LUA_PLUGIN_INSTANCE_VAR_NAME);
if (!lua_islightuserdata(L, -1))
{
- LOGERROR("%s: cannot get plugin instance, what have you done to my Lua state?", __FUNCTION__);
+ LOGWARNING("%s: cannot get plugin instance, what have you done to my Lua state?", __FUNCTION__);
+ lua_pop(L);
return NULL;
}
cPlugin_NewLua * Plugin = (cPlugin_NewLua *)lua_topointer(L, -1);