What command do I use to read the contents of this file? thank youlocal quickbar = {.........}
local text = game.table_to_json(quickbar)
game.write_file("save/quick-bar.json",text)
How to read the file contents in the user data folder
How to read the file contents in the user data folder
I saved one of my forms in the "script output" folder. The official wiki only said how to write it, but I didn't find out how to read it
Re: How to read the file contents in the user data folder
No one to help? I really need this answer
Re: How to read the file contents in the user data folder
There is no such thing as "read a file". When a script is running in a multiplayer game, every instance of the game would be trying to read the same file from different machine and if the content would be different a desync would happen. Primary way of mutable data storage is through a variable named "global" in Lua context, which is part of the save file.
Re: How to read the file contents in the user data folder
Thank you for your reply. My idea is like this. I want to save the content of "quickbar" to a file so that it can be automatically read when I start a new game next time. So my idea can't be realized? Is that so?boskid wrote: ↑Mon Aug 01, 2022 10:20 amThere is no such thing as "read a file". When a script is running in a multiplayer game, every instance of the game would be trying to read the same file from different machine and if the content would be different a desync would happen. Primary way of mutable data storage is through a variable named "global" in Lua context, which is part of the save file.
Re: How to read the file contents in the user data folder
Yes, you are correct that it cannot be realized in that form. There are alternative ways to transfer settings, for example by doing it like map exchange strings (player imports and exports). Here is a mod that does that with the quickbar: https://mods.factorio.com/mod/quickbarimportexport
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: How to read the file contents in the user data folder
thank youBilka wrote: ↑Mon Aug 01, 2022 12:50 pmYes, you are correct that it cannot be realized in that form. There are alternative ways to transfer settings, for example by doing it like map exchange strings (player imports and exports). Here is a mod that does that with the quickbar: https://mods.factorio.com/mod/quickbarimportexport