update entities.spawn(...) semantics to the docs state

This commit is contained in:
MihailRis
2024-07-17 10:17:20 +03:00
parent 51a57d3d1f
commit 1b99a48849
9 changed files with 23 additions and 13 deletions
+5 -2
View File
@@ -20,9 +20,12 @@ static int l_spawn(lua::State* L) {
auto defname = lua::tostring(L, 1);
auto& def = content->entities.require(defname);
auto pos = lua::tovec3(L, 2);
dynamic::Value args = dynamic::NONE;
dynamic::Map_sptr args = nullptr;
if (lua::gettop(L) > 2) {
args = lua::tovalue(L, 3);
auto value = lua::tovalue(L, 3);
if (auto map = std::get_if<dynamic::Map_sptr>(&value)) {
args = *map;
}
}
level->entities->spawn(def, pos, args);
return 1;