even though the docs say:
See https://lua-api.factorio.com/latest/LuaRendering.htmlNote: If an entity target of an object is destroyed or changes surface, then the object is also destroyed.
Steps to reproduce:
1. Start a new game and execute this command:
Code: Select all
/c for i = 0, 10000, 1 do
local e = game.player.surface.create_entity{name="small-lamp", position={10,10}}
local r = rendering.draw_sprite{target=e,sprite="item.iron-ore",surface=game.player.surface}
e.destroy()
end
3. Execute the following command to confirm that renderings are the root cause:
Code: Select all
/c rendering.clear()
On the other hand if you destroy renderings manually using rendering.destroy(r) the "Script render preparation" doesn't raise.
Code: Select all
/c for i = 0, 10000, 1 do
local e = game.player.surface.create_entity{name="small-lamp", position={10,10}}
local r = rendering.draw_sprite{target=e,sprite="item.iron-ore",surface=game.player.surface}
rendering.destroy(r)
e.destroy()
end
Renderings attached to entities are properly destroyed when the entity is destroyed.