Event on_selection_changed request

jonatkins
Fast Inserter
Fast Inserter
Posts: 155
Joined: Wed Sep 30, 2015 7:29 pm
Contact:

Event on_selection_changed request

Post by jonatkins »

There's a "selected" property in LuaPlayer (actually LuaControl), but, as far as I can tell, no event fires when this changes.

Perhaps add an on_selected_changed event, with event parameters specifying
  • the player
  • the newly selected item (or nil if deselecting)
  • the previously selected item (or nil if not set)
Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: Event on_selection_changed request

Post by Supercheese »

This event would fire a bazillion times per game, though, possibly leading to bloat due to needing to log every event...
jonatkins
Fast Inserter
Fast Inserter
Posts: 155
Joined: Wed Sep 30, 2015 7:29 pm
Contact:

Re: Event on_selection_changed request

Post by jonatkins »

Logging every event? You mean with replays enabled?

Anyway, the data might already be recorded - to update the state of player.selected property.

For now, in my mod, I've added code to monitor for changes to player.selected in on_tick - so it's already possible, but a little ugly and inefficient compared to a dedicated event.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Event on_selection_changed request

Post by aubergine18 »

The event could potentially be despammed - so that a selection must persist for 500ms or 750ms before the event is fired.

It will certainly be less crufty than having a bunch of mods checking the selection state of all players via on_tick handlers.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14913
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Event on_selection_changed request

Post by Rseding91 »

Added for 0.15.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Implemented mod requests”