summaryrefslogtreecommitdiff
path: root/src/scripting/luascript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/scripting/luascript.cpp')
-rw-r--r--src/scripting/luascript.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/scripting/luascript.cpp b/src/scripting/luascript.cpp
index dfa64d0f..e45588b9 100644
--- a/src/scripting/luascript.cpp
+++ b/src/scripting/luascript.cpp
@@ -118,10 +118,11 @@ void LuaScript::push(const std::list<InventoryItem> &itemList)
int LuaScript::execute()
{
assert(nbArgs >= 0);
- assert(!mCurrentThread);
- int res = lua_pcall(mCurrentState, nbArgs, 1, 1);
+
+ const int tmpNbArgs = nbArgs;
nbArgs = -1;
+ int res = lua_pcall(mCurrentState, tmpNbArgs, 1, 1);
if (res || !(lua_isnil(mCurrentState, -1) || lua_isnumber(mCurrentState, -1)))
{
@@ -144,8 +145,9 @@ bool LuaScript::resume()
assert(mCurrentThread);
setMap(mCurrentThread->mMap);
- int result = lua_resume(mCurrentState, nbArgs);
+ const int tmpNbArgs = nbArgs;
nbArgs = -1;
+ int result = lua_resume(mCurrentState, tmpNbArgs);
setMap(0);
if (result == 0) // Thread is done