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:
Pictures:
Last user: not me 2017-02-16 00_46_38-Factorio 0.14.22.png (158.43 KiB) Viewed 1483 times
Why it was me? 2017-02-16 00_47_13-Factorio 0.14.22.png (74.59 KiB) Viewed 1483 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 This is just example of prototype definition, if someone does not know about this type of items.
Code: Select all
{type = "selection-tool",
name = "outposts-creation-tool",
icons = {{
icon= "__base__/graphics/icons/blueprint.png",
tint={r=0,g=1,b=0,a=1}
}},
flags = {"goes-to-quickbar"},
subgroup = "tool",
order = "c[automated-construction]-a[blueprint]",
stack_size = 1,
stackable = false,
selection_color = { r = 0, g = 1, b = 0 },
alt_selection_color = { r = 0, g = 1, b = 0 },
selection_mode = {"blueprint"},
alt_selection_mode = {"blueprint"},
selection_cursor_box_type = "copy",
alt_selection_cursor_box_type = "copy"
}