Hey,
it would nice to get the entity that is currently selected, if one is selected, as third output out of the event.
Because otherwise we always need to do game.players[event.player_index].selected.
Greetz,
Luzifer
on_selected_entity_changed::entity (optional)
- LuziferSenpai
- Filter Inserter
- Posts: 380
- Joined: Tue Jul 08, 2014 10:06 am
- Contact:
Re: on_selected_entity_changed::entity (optional)
+1
It will be very helpful by this mod: https://mods.factorio.com/mod/TorchLight
Right now it needs to check every player's selected_entity on every tick.
It will be very helpful by this mod: https://mods.factorio.com/mod/TorchLight
Right now it needs to check every player's selected_entity on every tick.
Re: on_selected_entity_changed::entity (optional)
And whats wrong with doing that?LuziferSenpai wrote: ↑Mon Apr 27, 2020 9:12 am Because otherwise we always need to do game.players[event.player_index].selected.
Re: on_selected_entity_changed::entity (optional)
Building a player object just to check if there is an entity under cursor.Klonan wrote: ↑Mon Apr 27, 2020 9:48 amAnd whats wrong with doing that?LuziferSenpai wrote: ↑Mon Apr 27, 2020 9:12 am Because otherwise we always need to do game.players[event.player_index].selected.
On cpp side you should already know if there's an entity in which case passing it along would be simple.
My Mods: mods.factorio.com
- LuziferSenpai
- Filter Inserter
- Posts: 380
- Joined: Tue Jul 08, 2014 10:06 am
- Contact:
Re: on_selected_entity_changed::entity (optional)
What Optera says, to check if a player has something selected is just so much performance cost.Klonan wrote: ↑Mon Apr 27, 2020 9:48 amAnd whats wrong with doing that?LuziferSenpai wrote: ↑Mon Apr 27, 2020 9:12 am Because otherwise we always need to do game.players[event.player_index].selected.
Re: on_selected_entity_changed::entity (optional)
The exact reason why you want it added is the exact reason why it doesn't exist. You would pay that performance cost every time the event fired to push the new LuaEntity into the event handler.
Instead, cache the player on your end if its that slow and you want to read it.
Instead, cache the player on your end if its that slow and you want to read it.
If you want to get ahold of me I'm almost always on Discord.
- LuziferSenpai
- Filter Inserter
- Posts: 380
- Joined: Tue Jul 08, 2014 10:06 am
- Contact:
Re: on_selected_entity_changed::entity (optional)
Then why do you pass last_entity? It would be the same result. I dont understand that, but okay ...Rseding91 wrote: ↑Mon Apr 27, 2020 5:17 pm The exact reason why you want it added is the exact reason why it doesn't exist. You would pay that performance cost every time the event fired to push the new LuaEntity into the event handler.
Instead, cache the player on your end if its that slow and you want to read it.
Re: on_selected_entity_changed::entity (optional)
Because there's no other way to get it.LuziferSenpai wrote: ↑Mon Apr 27, 2020 5:25 pmThen why do you pass last_entity? It would be the same result. I dont understand that, but okay ...Rseding91 wrote: ↑Mon Apr 27, 2020 5:17 pm The exact reason why you want it added is the exact reason why it doesn't exist. You would pay that performance cost every time the event fired to push the new LuaEntity into the event handler.
Instead, cache the player on your end if its that slow and you want to read it.
If you want to get ahold of me I'm almost always on Discord.