[2.0.47] Issue with LuaPlanet associate_surface

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
orzelek
Smart Inserter
Smart Inserter
Posts: 3928
Joined: Fri Apr 03, 2015 10:20 am
Contact:

[2.0.47] Issue with LuaPlanet associate_surface

Post 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.
Attachments
warptorio-space-age_0.0.19.zip
(8.65 MiB) Downloaded 14 times
rso-mod_7.0.16.zip
(136.96 KiB) Downloaded 13 times
Test.zip
(5.72 MiB) Downloaded 14 times
Rseding91
Factorio Staff
Factorio Staff
Posts: 15554
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.47] Issue with LuaPlanet associate_surface

Post 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"
If you want to get ahold of me I'm almost always on Discord.
orzelek
Smart Inserter
Smart Inserter
Posts: 3928
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [2.0.47] Issue with LuaPlanet associate_surface

Post 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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15554
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.47] Issue with LuaPlanet associate_surface

Post 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
If you want to get ahold of me I'm almost always on Discord.
orzelek
Smart Inserter
Smart Inserter
Posts: 3928
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [2.0.47] Issue with LuaPlanet associate_surface

Post 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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15554
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.47] Issue with LuaPlanet associate_surface

Post by Rseding91 »

Ah event when a surface is associated could be added. It doesn't seem unreasonable.
If you want to get ahold of me I'm almost always on Discord.
orzelek
Smart Inserter
Smart Inserter
Posts: 3928
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [2.0.47] Issue with LuaPlanet associate_surface

Post by orzelek »

It would be very helpful - only solution right now would be to check every chunk event if planet of surface has changed.
Post Reply

Return to “Modding interface requests”