Load tons of files

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Linver
Fast Inserter
Fast Inserter
Posts: 158
Joined: Wed Jan 09, 2019 2:28 pm
Contact:

Load tons of files

Post by Linver »

Hi guy,
In data (any phase) of a mod, I have a case like one folder(let's call it A) with many lua file of inizialization of prototypes (is divided for make order), and I want load all files without have to write "require() require() require() require()..." exist a sort of require(A/*)?

Honktown
Smart Inserter
Smart Inserter
Posts: 1026
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: Load tons of files

Post by Honktown »

Linver wrote:
Thu Nov 07, 2019 6:59 pm
Hi guy,
In data (any phase) of a mod, I have a case like one folder(let's call it A) with many lua file of inizialization of prototypes (is divided for make order), and I want load all files without have to write "require() require() require() require()..." exist a sort of require(A/*)?
You can have a dependencies.lua file, and if certain settings are true or not (don't need to be in-game settings) then a whole bunch of requires are pulled in.
I have mods! I guess!
Link

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Load tons of files

Post by eradicator »

Linver wrote:
Thu Nov 07, 2019 6:59 pm
exist a sort of require(A/*)?
No, the best you can do is using a table that represents the directory structure (possible script-generated). Then build the paths on-the-fly. That way you "only" have to list the filename and directory names once each.
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.

Post Reply

Return to “Modding help”