Page 1 of 1
event.on_entity_died - killer info
Posted: Sun Feb 12, 2017 5:42 pm
by darkfrei
Hi! Can you add
player_index info who killed this entity? Now it's available by creating, deconstructing, but not by entities, that were killed by the player.
Code: Select all
on_entity_died
Called when an entity dies.
Contains
entity :: LuaEntity
force :: LuaForce (optional): The force that did the killing if any.
Re: event.on_entity_died - killer info
Posted: Sun Feb 12, 2017 7:34 pm
by daniel34
viewtopic.php?f=65&t=34553
Rseding91 wrote:Added for 0.15. It's an optional field as it's not always available.
Re: event.on_entity_died - killer info
Posted: Sun Feb 12, 2017 7:35 pm
by darkfrei
Code: Select all
script.on_event(defines.events.on_marked_for_deconstruction, function(event)
-- on_marked_for_deconstruction
-- Called when an entity is marked for deconstruction with the Deconstruction planner or via script.
-- Contains
-- entity :: LuaEntity
-- player_index :: uint (optional)
local player_index = event.player_index
local entity = event.entity
if not entity.last_user then return end
printAll("Last user: " .. entity.last_user.index)
end)
I don't know why, but I get my index, not the index of
last_user. Must it be in event.on_premarked_for_deconstruction?