Add event.surface to on_player_selected_area

Post Reply
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Add event.surface to on_player_selected_area

Post by darkfrei »

Can you please add the surface to this event?
https://lua-api.factorio.com/latest/eve ... ected_area
on_player_selected_area
Called after a player selects an area with a selection-tool item.

Contains
player_index :: uint: The player doing the selection.
area :: BoundingBox: The area selected.
item :: string: The item used to select the area.
entities :: array of LuaEntity: The entities selected.
tiles :: array of LuaTile: The tiles selected.
The information about area without surface is not full.

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

Re: Add event.surface to on_player_selected_area

Post by Rseding91 »

The surface is the player.surface. But I also don't mind adding it to the event.
If you want to get ahold of me I'm almost always on Discord.

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

Re: Add event.surface to on_player_selected_area

Post by darkfrei »

Rseding91 wrote:
Sun Mar 01, 2020 5:20 pm
The surface is the player.surface. But I also don't mind adding it to the event.
There is actually no player, but
local surface = game.players[event.player_index].surface
instead of just
local surface = event.surface

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

Re: Add event.surface to on_player_selected_area

Post by Rseding91 »

darkfrei wrote:
Sun Mar 01, 2020 6:14 pm
Rseding91 wrote:
Sun Mar 01, 2020 5:20 pm
The surface is the player.surface. But I also don't mind adding it to the event.
There is actually no player, but
local surface = game.players[event.player_index].surface
instead of just
local surface = event.surface
I know. It's that way on purpose because making the player object for every event when in a lot of cases event handlers don't care about the player would use a lot of extra CPU time.
If you want to get ahold of me I'm almost always on Discord.

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

Re: Add event.surface to on_player_selected_area

Post by darkfrei »

Rseding91 wrote:
Sun Mar 01, 2020 6:16 pm
darkfrei wrote:
Sun Mar 01, 2020 6:14 pm
Rseding91 wrote:
Sun Mar 01, 2020 5:20 pm
The surface is the player.surface. But I also don't mind adding it to the event.
There is actually no player, but
local surface = game.players[event.player_index].surface
instead of just
local surface = event.surface
I know. It's that way on purpose because making the player object for every event when in a lot of cases event handlers don't care about the player would use a lot of extra CPU time.
So the game.players[event.player_index].surface needs at least the same amount CPU time as event.player?

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

Re: Add event.surface to on_player_selected_area

Post by Rseding91 »

No, but most event handlers won't use the player index value.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Implemented mod requests”