Page 1 of 1

[2.0.47] Issue with LuaPlanet associate_surface

Posted: Fri May 02, 2025 5:47 pm
by orzelek
I have been trying to make RSO work with warptorio correctly but I don't seem to be able to follow planet=surface associacion after warptorio used associate_surface call on planet.

After that call surface that was just created has planet set to nil in lua, at the same time if I iterate on planets and check their surface the planet in question has nil as surface.

I'm attaching Test save (just click warp to jump to gleba that won't spawn resources).
Attached also rso and warptorio mods with logging.
Log output points shows that RSO can't find surface/planet connection when trying to figure out which config use for resources:

Code: Select all

  98.852 Script @__rso-mod__/control.lua:1931: RSO: Updated resource configurations
 101.144 Script @__warptorio-space-age__/control.lua:392: Generating surface:gleba
 101.147 Script @__rso-mod__/control.lua:1823: Checking nauvis surface nauvis
 101.147 Script @__rso-mod__/control.lua:1823: Checking vulcanus surface none
 101.147 Script @__rso-mod__/control.lua:1823: Checking gleba surface none
 101.147 Script @__rso-mod__/control.lua:1823: Checking fulgora surface none
 101.147 Script @__rso-mod__/control.lua:1823: Checking aquilo surface none
 101.147 Script @__rso-mod__/control.lua:1831: surface warpzone_5 planet name none
Game will correctly spawn gleba on warpzone_5 sufrace.

Re: [2.0.47] Issue with LuaPlanet associate_surface

Posted: Mon May 05, 2025 1:44 pm
by Rseding91
I'm unable to reproduce any issues when I test manually which makes me think maybe the Lua logic is misunderstanding how it works?

1. Start a new game
2. /c storage.surface = game.create_surface("test")
3. /c game.planets.gleba.associate_surface(storage.surface)
4. /c game.print(game.planets.gleba.surface.name)
5. /c game.print(game.surfaces.test.planet.name)

#4 prints "test"
#5 prints "gleba"

Re: [2.0.47] Issue with LuaPlanet associate_surface

Posted: Fri May 09, 2025 4:18 pm
by orzelek
It's possible that problem happens within one event.
Your test makes all of those separate command - when I'm trying to spawn stuff on surface it happens right after surface was created and attached to planet. I think it's in the same event and/or block of lua (would need to double check to be sure).
I know that code that made surface uses force gen for chunks and I think that is where my code tries to get to planet. Since it's placed in on chunk generated event handler in RSO.

Re: [2.0.47] Issue with LuaPlanet associate_surface

Posted: Fri May 09, 2025 4:46 pm
by Rseding91
You can combine them all into one command and run it without issue:

Code: Select all

/c storage.surface = game.create_surface("test"); game.planets.gleba.associate_surface(storage.surface); game.print(game.planets.gleba.surface.name); game.print(game.surfaces.test.planet.name)
factorio_kc2byiuixR.mp4
(6.14 MiB) Downloaded 10 times

Re: [2.0.47] Issue with LuaPlanet associate_surface

Posted: Fri May 09, 2025 7:34 pm
by orzelek
Thanks for checking I think I figured it out with help of error().
Issue happens because RSO acts on surface create and then there is no surface association yet.

From what I can see there is no event that informs about change of surface association so I'll have to find a workaround for that.

Re: [2.0.47] Issue with LuaPlanet associate_surface

Posted: Fri May 09, 2025 9:08 pm
by Rseding91
Ah event when a surface is associated could be added. It doesn't seem unreasonable.

Re: [2.0.47] Issue with LuaPlanet associate_surface

Posted: Sat May 10, 2025 12:14 pm
by orzelek
It would be very helpful - only solution right now would be to check every chunk event if planet of surface has changed.