[posila] deconstruction order on item request proxy event
Posted: Thu Jan 16, 2020 3:53 am
Steps to reproduce:
1. Use entity.order_deconstruction(...) on an item request proxy
2. Have a function called on the event on_marked_for_deconstruction
3. Have that function order entity.destroy()
4. crash
Note, that at step 3 entity.valid still returns true. I am using a heavily modded game, which does not help you, which is why i dont include a save game.
If the function checks, that entity.name is not "item-request-proxy", it just works. I am convinced I nailed down the problem to that.
Also, if you drag a deconstruction planer over the area containing the item request proxy, there is no issue. So, even if you call entity.destroy() on_marked_for_deconstruction, the game works.
I created most of a small test mod. With this, the steps to reproduce become:
1. build an entity with item requests, eg a blueprint of a beacon or assembler with modules. It will get instantly placed.
2. change test to true.
I have not tested this yet, becouse its 5 am and i want to sleep.
Control:
Settings:
1. Use entity.order_deconstruction(...) on an item request proxy
2. Have a function called on the event on_marked_for_deconstruction
3. Have that function order entity.destroy()
4. crash
Note, that at step 3 entity.valid still returns true. I am using a heavily modded game, which does not help you, which is why i dont include a save game.
If the function checks, that entity.name is not "item-request-proxy", it just works. I am convinced I nailed down the problem to that.
Also, if you drag a deconstruction planer over the area containing the item request proxy, there is no issue. So, even if you call entity.destroy() on_marked_for_deconstruction, the game works.
I created most of a small test mod. With this, the steps to reproduce become:
1. build an entity with item requests, eg a blueprint of a beacon or assembler with modules. It will get instantly placed.
2. change test to true.
I have not tested this yet, becouse its 5 am and i want to sleep.
Control:
Code: Select all
local function marked_for_decon(event)
if settings.global["instant_bp_and_decon"].value then
local ent =event.entity
if ent.valid then
ent.destroy()
end
end
end
local function on_Tick(event)
if settings.global["test"].value then
global.irp.mark_for_deconstruction(global.irp.force)
end
end
local function on_built(event)
local ent=event.created_entity
if settings.global["instant_bp_and_decon"].value and (ent.name == "entity-ghost") then
ent.revive()
end
if ent.name = "item-request-proxy" then
global.irp = ent
end
end
script.on_event(defines.events.on_marked_for_deconstruction,marked_for_decon)
script.on_event(defines.events.on_tick,on_Tick)
script.on_event(defines.events.on_built_entity,on_built)
Code: Select all
data:extend({
{
type = "bool-setting",
name = "instant_bp_and_decon",
setting_type = "runtime-global",
default_value = true
},
{
type = "bool-setting",
name = "test",
setting_type = "runtime-global",
default_value = false
}
})