mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
improved syncing of players between C++ and Lua
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user