mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
update entities.spawn(...) semantics to the docs state
This commit is contained in:
parent
51a57d3d1f
commit
1b99a48849
9 changed files with 23 additions and 13 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue