Page 1 of 1

Wrond index: on_marked_for_deconstruction - entity.player_index

Posted: Wed Feb 15, 2017 11:51 pm
by darkfrei
The code:

Code: Select all

script.on_event(defines.events.on_marked_for_deconstruction, function(event)

	local player_index = event.player_index
	local entity = event.entity
	if not entity.last_user then return end
	
	for index in pairs(game.players) do
		game.players[index].print("Last user: " .. entity.last_user.name)
	end
end)
Mod:
MassDeconstructInfo_0.0.1.zip
(866 Bytes) Downloaded 70 times
Pictures:
Last user: not me
Last user: not me
2017-02-16 00_46_38-Factorio 0.14.22.png (158.43 KiB) Viewed 1480 times
Why it was me?
Why it was me?
2017-02-16 00_47_13-Factorio 0.14.22.png (74.59 KiB) Viewed 1480 times
Is event.player_index and event.entity.last_user.index the same?

Re: Wrond index: on_marked_for_deconstruction - entity.player_index

Posted: Thu Feb 16, 2017 12:08 am
by Rseding91
It was you because it's changed when you marked it for deconstruction. It wasn't marked and now it is thus you changed it.

Re: Wrond index: on_marked_for_deconstruction - entity.player_index

Posted: Thu Feb 16, 2017 11:17 am
by darkfrei
Rseding91 wrote:It was you because it's changed when you marked it for deconstruction. It wasn't marked and now it is thus you changed it.
There is no on_premarked_for_deconstruction, then how to check, who was last_user earlier and who has marked this entity to deconstruction?

Re: Wrond index: on_marked_for_deconstruction - entity.player_index

Posted: Thu Feb 16, 2017 6:50 pm
by Rseding91
darkfrei wrote:
Rseding91 wrote:It was you because it's changed when you marked it for deconstruction. It wasn't marked and now it is thus you changed it.
There is no on_premarked_for_deconstruction, then how to check, who was last_user earlier and who has marked this entity to deconstruction?
You can't. The event and that field were not designed to be used together like that.

Re: Wrond index: on_marked_for_deconstruction - entity.player_index

Posted: Thu Feb 16, 2017 9:58 pm
by Adil
I didn't test this but doesn't simple selection tool leave the user field unchanged?
For those unfamiliar