[1.1.69] not-modded luasurface.get_tile() returns invalid tile

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

[1.1.69] not-modded luasurface.get_tile() returns invalid tile

Post by Honktown »

If a tile is in a chunk that's not generated(?) get_tile returns an invalid tile:
1) start new game

Code: Select all

/c
local tile = game.player.surface.get_tile(1000, 0)
game.print(tile.name)
Expectation: The game should not return invalid objects. No tile (new change) or valid tile should be the only returns?
I have mods! I guess!
Link

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

Re: [1.1.69] not-modded luasurface.get_tile() returns invalid tile

Post by Rseding91 »

Thanks for the report however I don't see this changing in 1.1 since it would break every mod that uses the API and expects non-nil from the function call. It has worked that way since it was added and can easily be .valid checked to see if the chunk exists.

We could probably change it for 1.2.
If you want to get ahold of me I'm almost always on Discord.

curiosity
Filter Inserter
Filter Inserter
Posts: 324
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: [1.1.69] not-modded luasurface.get_tile() returns invalid tile

Post by curiosity »

You probably should. It's a pretty major expectation.

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

Re: [1.1.69] not-modded luasurface.get_tile() returns invalid tile

Post by Rseding91 »

curiosity wrote:
Tue Sep 20, 2022 2:33 pm
You probably should. It's a pretty major expectation.
You didn't say what should be done.
If you want to get ahold of me I'm almost always on Discord.

curiosity
Filter Inserter
Filter Inserter
Posts: 324
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: [1.1.69] not-modded luasurface.get_tile() returns invalid tile

Post by curiosity »

Rseding91 wrote:
Tue Sep 20, 2022 2:43 pm
You didn't say what should be done.
Maintain the expectation.

Xorimuth
Filter Inserter
Filter Inserter
Posts: 624
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: [1.1.69] not-modded luasurface.get_tile() returns invalid tile

Post by Xorimuth »

Surely any mod that is expecting a non-nil result from get_tile is also expecting a valid result? What could a mod do with an invalid LuaTile that it can't do with a nil LuaTile?
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings

pleegwat
Filter Inserter
Filter Inserter
Posts: 258
Joined: Fri May 19, 2017 7:31 pm
Contact:

Re: [1.1.69] not-modded luasurface.get_tile() returns invalid tile

Post by pleegwat »

The existing interface is that a LuaTile is always returned and you need to check .valid. So most likely all existing mods assume the returned value is non-nil and check .valid, which would trigger an error if they suddenly got nil.

curiosity
Filter Inserter
Filter Inserter
Posts: 324
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: [1.1.69] not-modded luasurface.get_tile() returns invalid tile

Post by curiosity »

pleegwat wrote:
Wed Sep 21, 2022 4:51 pm
The existing interface is that a LuaTile is always returned and you need to check .valid. So most likely all existing mods assume the returned value is non-nil and check .valid, which would trigger an error if they suddenly got nil.
Supposedly they check valid. Most likely, I would guess, they don't.

Post Reply

Return to “Modding interface requests”