Wrond index: on_marked_for_deconstruction - entity.player_index

Place to get help with not working mods / modding interface.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Wrond index: on_marked_for_deconstruction - entity.player_index

Post 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 64 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 1379 times
Why it was me?
Why it was me?
2017-02-16 00_47_13-Factorio 0.14.22.png (74.59 KiB) Viewed 1379 times
Is event.player_index and event.entity.last_user.index the same?
Rseding91
Factorio Staff
Factorio Staff
Posts: 15998
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Wrond index: on_marked_for_deconstruction - entity.player_index

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Wrond index: on_marked_for_deconstruction - entity.player_index

Post 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?
Rseding91
Factorio Staff
Factorio Staff
Posts: 15998
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Wrond index: on_marked_for_deconstruction - entity.player_index

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Wrond index: on_marked_for_deconstruction - entity.player_index

Post by Adil »

I didn't test this but doesn't simple selection tool leave the user field unchanged?
For those unfamiliar
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
Post Reply

Return to “Modding help”