Add surface property to LuaTile

Post Reply
User avatar
Linver
Fast Inserter
Fast Inserter
Posts: 158
Joined: Wed Jan 09, 2019 2:28 pm
Contact:

Add surface property to LuaTile

Post by Linver »

Hi, I just wondering if is possible add to class LuaTile the surface[R] property. There's some cases where from set of returned tiles is impossible to understand in what surface they are, for example in the event on_player_selected_area:

Code: Select all

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 surface must be deduced from game.players[event.player_index].character.surface (entities can be empty), but is not written in documentation that guaranteed that the surface of player is the same of the selection (consequently of the tiles inside of the selected area), in that case there's no way to get this information.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Add surface property to LuaTile

Post by eradicator »

Linver wrote:
Tue Feb 18, 2020 7:06 pm
is not written in documentation that guaranteed that the surface of player is the same of the selection (consequently of the tiles inside of the selected area)
This is implicitly guaranteed as a player can not interact (i.e. draw selection boxes) with surfaces that they don't see. And they only sees the surfaces they're on right now.

LuaTile.surface might still have some uses when storing the wrapper object in global.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Linver
Fast Inserter
Fast Inserter
Posts: 158
Joined: Wed Jan 09, 2019 2:28 pm
Contact:

Re: Add surface property to LuaTile

Post by Linver »

Hi eradicator, so if I have understand because LuaPlayer and player character(LuaEntity) both extend LuaControl, they have surface property, but surface for LuaPlayer is in what surface the player camera is in that tick and for character is where the actual associeted character is?

Anyway in this case then it is solved, but I must store the surface associeted to a tile set of my own, still strange that I can't safe store a LuaTile that later in code I don't know from what surface they come from.

Bilka
Factorio Staff
Factorio Staff
Posts: 3133
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Add surface property to LuaTile

Post by Bilka »

Okay, added LuaTile::surface read for the next version.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Add surface property to LuaTile

Post by eradicator »

Linver wrote:
Wed Feb 19, 2020 7:21 am
but surface for LuaPlayer is in what surface the player camera is in that tick and for character is where the actual associeted character is?
I can't think of any possible situation where LuaPlayer.charater.surface is not equal to LuaPlayer.surface. Only LuaPlayer.get_associated_characters() can be on a different surface than the owning player. LuaControl is not relevant for that.
Bilka wrote:
Wed Feb 19, 2020 7:42 am
Okay, added LuaTile::surface read for the next version.
Great. Thanks :).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Add surface property to LuaTile

Post by Klonan »

eradicator wrote:
Wed Feb 19, 2020 3:06 pm
I can't think of any possible situation where LuaPlayer.charater.surface is not equal to LuaPlayer.surface.
Someone might raise an event

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Add surface property to LuaTile

Post by eradicator »

Klonan wrote:
Wed Feb 19, 2020 7:57 pm
eradicator wrote:
Wed Feb 19, 2020 3:06 pm
I can't think of any possible situation where LuaPlayer.charater.surface is not equal to LuaPlayer.surface.
Someone might raise an event
I can see how a broken mod can poison on_player_selected_area (*sigh*), but i don't see how that would affect above statement.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Implemented mod requests”