create_entity resource amount appears richer than default
Posted: Fri May 12, 2017 8:25 pm
I am cloning entities with the code at the bottom of this post. In-game I see that the "amount" of the cloned resource entities are the same, but the visual representation of the resource on the ground appears richer in the clone. In the screenshot, clone is left, original is right.
https://i.imgur.com/o3aM936.png
https://i.imgur.com/o3aM936.png
Code: Select all
local master_entities = surface.find_entities({master_pos, {master_pos.x+32, master_pos.y+32}})
for _, entity in ipairs(master_entities) do
if entity.type ~= "character" and entity.type ~= "player" then
local amount = entity.type == "resource" and entity.amount or nil
surface.create_entity{
name= entity.name,
position= {
x= (entity.position.x - master_pos.x) * slave_dx + slave_pos.x,
y= (entity.position.y - master_pos.y) * slave_dy + slave_pos.y
},
direction= entity.direction,
force= entity.force,
-- TODO: more thorough cloning
-- type-specific parameters
amount= amount,
}
end
end