Skip to content

Commit

Permalink
Trying something
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelIT7 committed Nov 24, 2023
1 parent 51b2ee8 commit 17e30be
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions source/lua_threaded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,8 @@ LUA_FUNCTION_STATIC(newindex)
return 0;
}

void RunString(ILuaInterface* LUA, const char* str)
void HandleError(ILuaInterface* LUA, int result)
{
int result = func_luaL_loadstring(LUA->GetState(), str);
Msg("[Code] %i\n", result);
if (result != 0)
{
const char* err = func_lua_tostring(LUA->GetState(), -1, NULL);
Expand All @@ -191,8 +189,16 @@ void RunString(ILuaInterface* LUA, const char* str)
Msg("[ERROR] ILuaInterface:RunString: %s\n", err);
return;
}
}

void RunString(ILuaInterface* LUA, const char* str)
{
int result = func_luaL_loadstring(LUA->GetState(), str);
Msg("[Code] %i\n", result);
HandleError(LUA, result);

LUA->PCall(0, LUA_MULTRET, 0);
result = LUA->PCall(0, 0, 0);
HandleError(LUA, result);
}

LUA_FUNCTION(ILuaInterface_RunString)
Expand All @@ -209,6 +215,8 @@ LUA_FUNCTION(ILuaInterface_RunString)
thread->mutex.Lock();
thread->actions.push_back(action);
thread->mutex.Unlock();

ThreadSleep(1000); // Remove it later
} else {
RunString(thread->IFace, str);
}
Expand Down

0 comments on commit 17e30be

Please sign in to comment.