mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-30 00:37:58 +03:00
Make SetLevelFunc and GetLevelFunc only store the function in m_levelFuncs.
Store the function in m_levelFuncs instead of the table itself.
This commit is contained in:
parent
b5d8fe06ad
commit
70cc036605
2 changed files with 16 additions and 15 deletions
|
@ -420,7 +420,10 @@ void GameScript::ResetLevelTables()
|
|||
|
||||
sol::protected_function GameScript::GetLevelFunc(sol::table tab, std::string const& luaName)
|
||||
{
|
||||
return tab.raw_get<sol::protected_function>(luaName);
|
||||
if (m_levelFuncs.find(luaName) == m_levelFuncs.end())
|
||||
return sol::lua_nil;
|
||||
|
||||
return m_levelFuncs.at(luaName);
|
||||
}
|
||||
|
||||
bool GameScript::SetLevelFunc(sol::table tab, std::string const& luaName, sol::object value)
|
||||
|
@ -429,11 +432,9 @@ bool GameScript::SetLevelFunc(sol::table tab, std::string const& luaName, sol::o
|
|||
{
|
||||
case sol::type::lua_nil:
|
||||
m_levelFuncs.erase(luaName);
|
||||
tab.raw_set(luaName, value);
|
||||
break;
|
||||
case sol::type::function:
|
||||
m_levelFuncs.insert(luaName);
|
||||
tab.raw_set(luaName, value);
|
||||
m_levelFuncs.insert_or_assign(luaName, value.as<sol::protected_function>());
|
||||
break;
|
||||
default:
|
||||
std::string error{ "Could not assign LevelFuncs." };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue