[2.1.9] Crash on LuaHelpers::write_file

Bugs which we just recently fixed in our development version and will reach you in the next release.
User avatar
RedRafe
Inserter
Inserter
Posts: 46
Joined: Thu Nov 11, 2021 12:21 pm
Contact:

[2.1.9] Crash on LuaHelpers::write_file

Post by RedRafe »

Hello,

game crashes when in control I use LuaHelpers::write_file with optional parameter "for_player=0"

Code: Select all

-- crashes in single player
helpers.write_file('file.json', data, false, 0)

-- does NOT crash in single player
helpers.write_file('file.json', data, false)
Attached is the log of the crash.
Attachments
feedback.log
(13.44 KiB) Downloaded 11 times
--- Factorio Modder, Admin & developer @ RedMew. Contact me via Discord. ---
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4662
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.1.9] Crash on LuaHelpers::write_file

Post by boskid »

I see, write_file's for_player was never implemented to work when control.lua top level is executed because at that stage it is not yet decided who is a local player or if thats a server. Before `helpers` existed, write_file was on `game` which was not available at that stage and it was not possible to do writes yet.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4662
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.1.9] Crash on LuaHelpers::write_file

Post by boskid »

Thanks for the report. Issue is now fixed for 2.1.10. When trying to use write_file with for_player != 0 from top level, write will be skipped because at that point local player cannot be decided yet. When using for_player == 0, it will not crash.
User avatar
RedRafe
Inserter
Inserter
Posts: 46
Joined: Thu Nov 11, 2021 12:21 pm
Contact:

Re: [2.1.9] Crash on LuaHelpers::write_file

Post by RedRafe »

Thanks, seems reasonable.
Can I also ask for this to be added to the new API docs when released (if not already taken care of).
Ty
--- Factorio Modder, Admin & developer @ RedMew. Contact me via Discord. ---
Bilka
Factorio Staff
Factorio Staff
Posts: 3816
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [2.1.9] Crash on LuaHelpers::write_file

Post by Bilka »

Docs updated for 2.1.10.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Post Reply

Return to “Resolved for the next release”