Page 1 of 1
on_selected_entity_changed::entity (optional)
Posted: Mon Apr 27, 2020 9:12 am
by LuziferSenpai
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
Re: on_selected_entity_changed::entity (optional)
Posted: Mon Apr 27, 2020 9:15 am
by darkfrei
+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.
Re: on_selected_entity_changed::entity (optional)
Posted: Mon Apr 27, 2020 9:48 am
by Klonan
LuziferSenpai wrote: ↑Mon Apr 27, 2020 9:12 am
Because otherwise we always need to do game.players[event.player_index].selected.
And whats wrong with doing that?
Re: on_selected_entity_changed::entity (optional)
Posted: Mon Apr 27, 2020 10:12 am
by Optera
Klonan wrote: ↑Mon Apr 27, 2020 9:48 am
LuziferSenpai wrote: ↑Mon Apr 27, 2020 9:12 am
Because otherwise we always need to do game.players[event.player_index].selected.
And whats wrong with doing that?
Building a player object just to check if there is an entity under cursor.
On cpp side you should already know if there's an entity in which case passing it along would be simple.
Re: on_selected_entity_changed::entity (optional)
Posted: Mon Apr 27, 2020 5:06 pm
by LuziferSenpai
Klonan wrote: ↑Mon Apr 27, 2020 9:48 am
LuziferSenpai wrote: ↑Mon Apr 27, 2020 9:12 am
Because otherwise we always need to do game.players[event.player_index].selected.
And whats wrong with doing that?
What Optera says, to check if a player has something selected is just so much performance cost.
Re: on_selected_entity_changed::entity (optional)
Posted: Mon Apr 27, 2020 5:17 pm
by Rseding91
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)
Posted: Mon Apr 27, 2020 5:25 pm
by LuziferSenpai
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.
Then why do you pass last_entity? It would be the same result. I dont understand that, but okay ...
Re: on_selected_entity_changed::entity (optional)
Posted: Mon Apr 27, 2020 5:30 pm
by Rseding91
LuziferSenpai wrote: ↑Mon Apr 27, 2020 5:25 pm
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.
Then why do you pass last_entity? It would be the same result. I dont understand that, but okay ...
Because there's no other way to get it.