Surface tiles resetting when player teleports

Place to get help with not working mods / modding interface.
Post Reply
SkarKorlan13
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun Jan 23, 2022 11:55 pm
Contact:

Surface tiles resetting when player teleports

Post by SkarKorlan13 »

I'm making a mod and trying to make a new surface, similar to Factorissimo factories, in that I want it to be a square made of concrete or some such material. Currently, before the player teleports, I am creating a surface of size 2x2, and then setting the tiles to be a 16x16 square of concrete tiles. The surface is created fine, but when I teleport the player, there seems to be one tick of the concrete being there and then the concrete disappears. I've tested setting the tiles when the player is in the surface with a custom input, and then it stays and works fine. Is the surface generation called when the player joins the surface for the first time or something? Any and all help is much appreciated.

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 490
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Surface tiles resetting when player teleports

Post by Silari »

Pretty sure the game generates chunks in a radius around the player, so once the player gets teleported it starts generating chunks, thus replacing what you made. You can set the chunks to generated to avoid it being changed (https://lua-api.factorio.com/latest/Lua ... ted_status), or make it generate the chunks manually (https://lua-api.factorio.com/latest/Lua ... ate_chunks and force_generate_chunk_requests() right after it) then make your tile changes.

SkarKorlan13
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun Jan 23, 2022 11:55 pm
Contact:

Re: Surface tiles resetting when player teleports

Post by SkarKorlan13 »

That makes sense, thanks for the help.

Post Reply

Return to “Modding help”