Thanks a lot but you will hate me since i found the solution before the approval of the modo 😬 :grimacing:
I think the Wiki must be updated since:
- there is no tutorial on how to write files from lua in CC
- the IO api is not enought documented
- the use of fs api provide missleading coding style with IO api (note the notation "." and ":" for the same purpose)
So if somone have the same issue than me i advise you to do the following.
you want to write some strings to a file. To do so you have 2 option:
- the hard way but more flexible way is to use IO library
- the quick and dirty yet powerfull way is to use FS library (CC endemic not sure if it is CraftOS endemic)
What you have to do is to create a file handle that ack like C type file handle:
Myownfile = io.open("myfile.txt","w")
Myownfile.write(Myownfile,"This is the first thing in my file")
Myownfile.close(Myownfile)
This code should do the trick but you can use less verbose and more efficient? notation
f = io.open("text_file.txt","w")
f:write("this is a test")
f:close()
Note the diference between dot notation "." and semicolon ":"
Thanks bomb bloke for your help !
I made a long post and i sure that i left some misspelling since english isn't my native language so if you notice something that hurt your eyes tell me i'll edit