Page 1 of 1
Add surface property to LuaTile
Posted: Tue Feb 18, 2020 7:06 pm
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.
Re: Add surface property to LuaTile
Posted: Tue Feb 18, 2020 7:25 pm
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.
Re: Add surface property to LuaTile
Posted: Wed Feb 19, 2020 7:21 am
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.
Re: Add surface property to LuaTile
Posted: Wed Feb 19, 2020 7:42 am
by Bilka
Okay, added LuaTile::surface read for the next version.
Re: Add surface property to LuaTile
Posted: Wed Feb 19, 2020 3:06 pm
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 :).
Re: Add surface property to LuaTile
Posted: Wed Feb 19, 2020 7:57 pm
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
Re: Add surface property to LuaTile
Posted: Wed Feb 19, 2020 8:26 pm
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.