ID:1678571
 
Keywords: coding, game, in
(See the best response by Kaiochao.)
Code:
                storycodes+="src.loc = locate([src.x], [src.y], src.storymap.z)"
storycodes+=" src.dir=[src.dir]"
var/savefile/F = new()
var/txtfile = file("stories/[src.key][src.name][src.storiesmade].dm")
var/list/Lsd=new()
for(var/o in src.storycodes)
Lsd+=o
F["Lsd"] << Lsd
F.ExportText("/",txtfile)


Problem description:

I'm doing something where players can create their own stories then translate it into code so it can be implemented and played again. This is also going to be easier/more fun for me to code it in. The main problem is that the codes don't create new lines and instead does something like this:
Lsd = list("src.loc = locate(5, 34, src.storymap.z)"," src.dir=2")

I read a thread awhile back that explained how to properly code in-game, but I can't find it anymore so can anyone help
Best response
You don't need a savefile, you just use text and text2file().

To add newlines, you use \n.

Note that if the file exists, the text will be added to the end.