mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +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
|
|
@ -301,7 +301,7 @@ void scripting::on_entity_spawn(
|
|||
const EntityDef&,
|
||||
entityid_t eid,
|
||||
const std::vector<std::unique_ptr<UserComponent>>& components,
|
||||
dynamic::Value args,
|
||||
dynamic::Map_sptr args,
|
||||
dynamic::Map_sptr saved
|
||||
) {
|
||||
auto L = lua::get_main_thread();
|
||||
|
|
@ -321,8 +321,14 @@ void scripting::on_entity_spawn(
|
|||
lua::get_from(L, lua::CHUNKS_TABLE, component->name, true);
|
||||
lua::pushenv(L, *compenv);
|
||||
|
||||
lua::pushvalue(L, args);
|
||||
lua::setfield(L, "ARGS");
|
||||
if (args != nullptr) {
|
||||
std::string compfieldname = component->name;
|
||||
util::replaceAll(compfieldname, ":", "__");
|
||||
if (auto datamap = args->map(compfieldname)) {
|
||||
lua::pushvalue(L, datamap);
|
||||
lua::setfield(L, "ARGS");
|
||||
}
|
||||
}
|
||||
|
||||
if (saved == nullptr) {
|
||||
lua::createtable(L, 0, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue