There is a directory with a ton of files in a scenario folder.
You don´t know the names of the files.
Is it possible to find all the files in that folder and require / load them all from within a scenario script?
Would love if this was doable somehow!
Require all files in a scenario directory.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Require all files in a scenario directory.
No love for you today. This is not supported in factorio. You have to explicitly require every file you need.
If you don't care for the loading order of all the files you can probably make a quick script with dir/ls that automatically creates the requirements for you.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Require all files in a scenario directory.
Sad, it would be so useful if this was doable somehow within the game.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Require all files in a scenario directory.
What is your usecase for loading arbitrary files? If it's just "it's annoying to write all the requires" that's just not a very good usecase :).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Require all files in a scenario directory.
Gathering data across play sessions in a comfortable nice way. Most useful for multiplayer values.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Require all files in a scenario directory.
I have no clue what you're trying to do there. If you need help you'll have to give more details (if not, then not :p).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Require all files in a scenario directory.
Something, like, writing the playtimes of players every session to files so you can gather a total playtime amount. Things like that.
Re: Require all files in a scenario directory.
Set the third parameter of game.write_file() to true, it appends everything to a single file.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Require all files in a scenario directory.
That data is already available via the API:
And even if it wasn't i see no need to store it into files instead of into the saves global data. So i'm still uncertain what your actual usecase might be @ "Things like that".LuaPlayer wrote: afk_time :: uint [R] How many ticks since the last action of this player
online_time :: uint [R] How many ticks did this player spend playing this save (all sessions combined)
Files written via game.write_file() can't be read back into a running game even if you did know the file names, becaues they're not in a directory accessible to the lua state. You'd have to manually move them into the mod/scenario after writing them.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Require all files in a scenario directory.
Yes and to load them back in, it would be helpful to just be able load all files in a directory.