diff options
Diffstat (limited to 'engines/sword25/script')
-rw-r--r-- | engines/sword25/script/lua_extensions.cpp | 4 | ||||
-rw-r--r-- | engines/sword25/script/luabindhelper.cpp | 13 | ||||
-rw-r--r-- | engines/sword25/script/luascript.cpp | 8 |
3 files changed, 16 insertions, 9 deletions
diff --git a/engines/sword25/script/lua_extensions.cpp b/engines/sword25/script/lua_extensions.cpp index f069da5075..91303ac8e0 100644 --- a/engines/sword25/script/lua_extensions.cpp +++ b/engines/sword25/script/lua_extensions.cpp @@ -66,8 +66,8 @@ static int Warning(lua_State *L) { // ----------------------------------------------------------------------------- static const luaL_reg GLOBAL_FUNCTIONS[] = { - "warning", Warning, - 0, 0, + {"warning", Warning}, + {0, 0} }; // ----------------------------------------------------------------------------- diff --git a/engines/sword25/script/luabindhelper.cpp b/engines/sword25/script/luabindhelper.cpp index 76e8faac8e..a4f42331e6 100644 --- a/engines/sword25/script/luabindhelper.cpp +++ b/engines/sword25/script/luabindhelper.cpp @@ -110,9 +110,7 @@ bool BS_LuaBindhelper::AddFunctionsToLib(lua_State *L, const Common::String &Lib lua_gettable(L, LUA_GLOBALSINDEX); RegisterPermanent(L, Functions->name); } - } - // If the table name is not empty, the functions are added to the given table - else { + } else { // If the table name is not empty, the functions are added to the given table // Ensure that the library table exists if (!_CreateTable(L, LibName)) return false; @@ -329,11 +327,13 @@ bool BS_LuaBindhelper::_CreateTable(lua_State *L, const Common::String &TableNam while (PartBegin) { const char *PartEnd = strchr(PartBegin, '.'); - if (!PartEnd) PartEnd = PartBegin + strlen(PartBegin); + if (!PartEnd) + PartEnd = PartBegin + strlen(PartBegin); Common::String SubTableName(PartBegin, PartEnd - PartBegin); // Tables with an empty string as the name are not allowed - if (SubTableName.size() == 0) return false; + if (SubTableName.size() == 0) + return false; // Verify that the table with the name already exists // The first round will be searched in the global namespace, with later passages @@ -344,7 +344,8 @@ bool BS_LuaBindhelper::_CreateTable(lua_State *L, const Common::String &TableNam } else { lua_pushstring(L, SubTableName.c_str()); lua_gettable(L, -2); - if (!lua_isnil(L, -1)) lua_remove(L, -2); + if (!lua_isnil(L, -1)) + lua_remove(L, -2); } // If it doesn't exist, create table diff --git a/engines/sword25/script/luascript.cpp b/engines/sword25/script/luascript.cpp index 2d475e1ed6..c6cfeb96ce 100644 --- a/engines/sword25/script/luascript.cpp +++ b/engines/sword25/script/luascript.cpp @@ -75,7 +75,8 @@ BS_LuaScriptEngine::BS_LuaScriptEngine(BS_Kernel *KernelPtr) : BS_LuaScriptEngine::~BS_LuaScriptEngine() { // Lua de-initialisation - if (m_State) lua_close(m_State); + if (m_State) + lua_close(m_State); } // ----------------------------------------------------------------------------- @@ -149,6 +150,7 @@ bool BS_LuaScriptEngine::ExecuteFile(const Common::String &FileName) { #ifdef DEBUG int __startStackDepth = lua_gettop(m_State); #endif + debug(0, "ExecuteFile(%s)", FileName.c_str()); // Get a pointer to the package manager BS_PackageManager *pPackage = static_cast<BS_PackageManager *>(BS_Kernel::GetInstance()->GetService("package")); @@ -219,6 +221,8 @@ bool BS_LuaScriptEngine::RegisterStandardLibs() { // ----------------------------------------------------------------------------- bool BS_LuaScriptEngine::ExecuteBuffer(const char *Data, unsigned int Size, const Common::String &Name) const { + debug(0, "ExecuteBuffer()"); + // Compile buffer if (luaL_loadbuffer(m_State, Data, Size, Name.c_str()) != 0) { BS_LOG_ERRORLN("Couldn't compile \"%s\":\n%s", Name.c_str(), lua_tostring(m_State, -1)); @@ -250,6 +254,8 @@ bool BS_LuaScriptEngine::ExecuteBuffer(const char *Data, unsigned int Size, cons // ----------------------------------------------------------------------------- void BS_LuaScriptEngine::SetCommandLine(const Common::StringArray &CommandLineParameters) { + debug(0, "SetCommandLine()"); + lua_newtable(m_State); for (size_t i = 0; i < CommandLineParameters.size(); ++i) { |