mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-30 00:37:58 +03:00
Added Debug Console Window
Added Script function that handles standalone script commands
This commit is contained in:
parent
feeaa3cb4b
commit
6fd9ce1473
3 changed files with 79 additions and 12 deletions
|
@ -1033,7 +1033,7 @@ void GameScript::FreeLevelScripts()
|
|||
*/
|
||||
}
|
||||
|
||||
string GameScript::loadScriptFromFile(char* luaFilename)
|
||||
string GameScript::loadScriptFromFile(const char* luaFilename)
|
||||
{
|
||||
ifstream ifs(luaFilename, ios::in | ios::binary | ios::ate);
|
||||
|
||||
|
@ -1046,10 +1046,9 @@ string GameScript::loadScriptFromFile(char* luaFilename)
|
|||
return string(bytes.data(), fileSize);
|
||||
}
|
||||
|
||||
bool GameScript::ExecuteScript(char* luaFilename, string* message)
|
||||
bool GameScript::ExecuteScript(const char* luaFilename, string* message)
|
||||
{
|
||||
sol::protected_function_result result;
|
||||
|
||||
result = m_lua->safe_script_file(luaFilename, sol::environment(m_lua->lua_state(), sol::create, m_lua->globals()), sol::script_pass_on_error);
|
||||
if (!result.valid())
|
||||
{
|
||||
|
@ -1061,6 +1060,20 @@ bool GameScript::ExecuteScript(char* luaFilename, string* message)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GameScript::ExecuteString(const char* command, string* message)
|
||||
{
|
||||
sol::protected_function_result result;
|
||||
result = m_lua->safe_script(command);
|
||||
if (!result.valid())
|
||||
{
|
||||
sol::error error = result;
|
||||
*message = error.what();
|
||||
return false;
|
||||
}
|
||||
message->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameScript::ExecuteTrigger(short index)
|
||||
{
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue