Code: Select all
script.on_event(defines.events.on_marked_for_deconstruction, function(ev)
game.players[1].print(tostring(ev.player_index) .. ", " .. tostring(ev.entity.built_by))
if ev.player_index and game.players[ev.player_index].cheat_mode then
ev.entity.destroy()
end
end)
I suppose it wouldn't make sense to have a built_by attribute for that entity if we eventually get a marked_by or marked_for_descontruction_by when somebody wants to access the player that marked something for deconstruction (for example, a mod that only allows the original deconstructor to cancel their own deconstruction).