Page 1 of 1
Add event.surface to on_player_selected_area
Posted: Sun Mar 01, 2020 4:14 pm
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.
Re: Add event.surface to on_player_selected_area
Posted: Sun Mar 01, 2020 5:20 pm
by Rseding91
The surface is the player.surface. But I also don't mind adding it to the event.
Re: Add event.surface to on_player_selected_area
Posted: Sun Mar 01, 2020 6:14 pm
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
Re: Add event.surface to on_player_selected_area
Posted: Sun Mar 01, 2020 6:16 pm
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.
Re: Add event.surface to on_player_selected_area
Posted: Mon Mar 02, 2020 8:11 am
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?
Re: Add event.surface to on_player_selected_area
Posted: Tue Mar 03, 2020 12:34 am
by Rseding91
No, but most event handlers won't use the player index value.