Making a mod list command but not working...

Place to get help with not working mods / modding interface.
Script20
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Aug 17, 2020 3:20 am

Making a mod list command but not working...

Post by Script20 »

I'm trying to figure stuff out with this game, so I have made a command that will get all the active mods and put it into a txt file.

Code: Select all

/c for name in pairs(script.active_mods) do game.print(name) end 
When you put that into the console it logs all the active mods, Great!

but if I change it to write it to a file I only get 1 mod not all of them...

Code: Select all

 /c for name in pairs(game.active_mods) do game.write_file("modlist.txt", name) end 
I'm not sure why it is only writing 1, it's obviously getting them all but not all are being written.
Creidhne
Inserter
Inserter
Posts: 28
Joined: Mon Jun 10, 2019 9:43 am
Contact:

Re: Making a mod list command but not working...

Post by Creidhne »

LuaGameScript.write_file() has a 3rd argument named append:

Code: Select all

append :: boolean (optional): When true, this will append to the end of the file. Defaults to false, which will overwrite any pre-existing file with the new data.
Setting it to true should solve your problem.
Script20
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Aug 17, 2020 3:20 am

Re: Making a mod list command but not working...

Post by Script20 »

Thank you so much bud it worked!
Post Reply

Return to “Modding help”