introduce local player

This commit is contained in:
MihailRis
2025-01-16 05:59:43 +03:00
parent b5999fe364
commit 65fec4f4a9
16 changed files with 84 additions and 31 deletions
+6
View File
@@ -55,10 +55,15 @@ static int l_new_world(lua::State* L) {
auto name = lua::require_string(L, 1);
auto seed = lua::require_string(L, 2);
auto generator = lua::require_string(L, 3);
int64_t localPlayer = 0;
if (lua::gettop(L) >= 4) {
localPlayer = lua::tointeger(L, 4);
}
if (level != nullptr) {
throw std::runtime_error("world must be closed before");
}
auto controller = engine->getController();
controller->setLocalPlayer(localPlayer);
controller->createWorld(name, seed, generator);
return 0;
}
@@ -71,6 +76,7 @@ static int l_open_world(lua::State* L) {
throw std::runtime_error("world must be closed before");
}
auto controller = engine->getController();
controller->setLocalPlayer(0);
controller->openWorld(name, false);
return 0;
}