Page 1 of 1

Making a mod list command but not working...

Posted: Mon Aug 17, 2020 3:27 am
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.

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

Posted: Mon Aug 17, 2020 8:45 am
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.

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

Posted: Tue Aug 18, 2020 1:12 am
by Script20
Thank you so much bud it worked!