trillek-team/tec

Centralize RegisterLuaType calls from server/main.cpp into LuaSystem

Closed this issue · 2 comments

tec/server/main.cpp

Lines 79 to 82 in 54682c7

tec::SaveGame::RegisterLuaType(lua_sys->GetGlobalState());
tec::UserList::RegisterLuaType(lua_sys->GetGlobalState());
tec::User::RegisterLuaType(lua_sys->GetGlobalState());
tec::networking::ClientConnection::RegisterLuaType(lua_sys->GetGlobalState());

A solution might be passing a lambda function to the lua system that registers the needed data types.
Doing so in the contructor of the systems that want to register data types would be best if possible, as we this way get rid of the function calls from main.cpp

Another solution would be to register a callback function in the LuaSystem when the system is constructed, later calling the registered function when the data is ready to expose