on_selected_entity_changed::entity (optional)

Things that we aren't going to implement
User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 380
Joined: Tue Jul 08, 2014 10:06 am
Contact:

on_selected_entity_changed::entity (optional)

Post 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
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: on_selected_entity_changed::entity (optional)

Post 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.
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5304
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: on_selected_entity_changed::entity (optional)

Post 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?
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: on_selected_entity_changed::entity (optional)

Post 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.
User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 380
Joined: Tue Jul 08, 2014 10:06 am
Contact:

Re: on_selected_entity_changed::entity (optional)

Post 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.
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai
Rseding91
Factorio Staff
Factorio Staff
Posts: 14720
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: on_selected_entity_changed::entity (optional)

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 380
Joined: Tue Jul 08, 2014 10:06 am
Contact:

Re: on_selected_entity_changed::entity (optional)

Post 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 ...
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai
Rseding91
Factorio Staff
Factorio Staff
Posts: 14720
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: on_selected_entity_changed::entity (optional)

Post 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.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Won't implement”