LuaEntity.clone{direction=...}
Posted: Wed Aug 26, 2020 5:48 pm
I have a mod that "clones" entities using LuaSurface.create_entity because it predates LuaEntity.clone. It was actually one of the two mods that inspired me to request clone way back when. Now I want to switch to using clone but I am stymied because some entities (like rails) can't have their direction changed after they are spawned. With create_entity I can specify the direction as part of the creation call, but with clone I can't. I need a direction parameter to clone to be able to use it for this use case.
Existing code:
Desired code:
Existing code:
Code: Select all
--TODO type-specific attributes
local new_entity = surface.create_entity{
name = entity.name,
position = pos,
direction = dir,
force = entity.force,
inner_name = entity.name == "entity-ghost" and entity.ghost_name or nil,
raise_built = true,
}
Code: Select all
local new_entity = entity.clone{position = pos, direction = dir}