event.on_entity_died - killer info

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

event.on_entity_died - killer info

Post 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.
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: event.on_entity_died - killer info

Post 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.
quick links: log file | graphical issues | wiki
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: event.on_entity_died - killer info

Post 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?
Post Reply

Return to “Implemented mod requests”