improved syncing of players between C++ and Lua

This commit is contained in:
devZoGok
2023-12-09 12:29:15 +02:00
parent bfa16ad8a2
commit 50ad223951
5 changed files with 34 additions and 10 deletions
+10
View File
@@ -29,7 +29,17 @@ namespace battleship{
return game;
}
void Game::resetLuaGameObjects(){
sol::state_view SOL_LUA_VIEW = generateView();
SOL_LUA_VIEW.script("game.players = {}");
for(int i = 0; i < players.size(); i++)
SOL_LUA_VIEW.script("game.players[" + to_string(i + 1) + "] = Player:new()");
}
void Game::update(){
resetLuaGameObjects();
for(int i = 0; i < players.size(); i++){
players[i]->update();