- ComputerCraft | Programmable Computers for Minecraft
- → Zepate's Content
Zepate's Content
There have been 3 items by Zepate (Search limited from 10-February 22)
#277502 [N00b] - Trouble using IO library
Posted by
Zepate
on 01 June 2018 - 02:36 PM
in
Ask a Pro
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:
you want to write some strings to a file. To do so you have 2 option:
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
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)
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)
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? notationf = 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
#277496 [N00b] - Trouble using IO library
Posted by
Zepate
on 01 June 2018 - 12:47 PM
in
Ask a Pro
Hello, i'm new to this forum and I am nice to meet you all.
I have trouble in creating files that i can read with CraftOS. For some reason I can write whatever i want without error but nothing is writen in the intented file.
to begin i use:
https://pasteboard.co/HnSwNkY.png
if i go back to craft os i have the folowing:

https://pasteboard.co/HnSxrAS.png
If i edit the test.txt with "edit test.txt" nothing is inside the file
Can someone help me please
I have trouble in creating files that i can read with CraftOS. For some reason I can write whatever i want without error but nothing is writen in the intented file.
to begin i use:
- minecraft 1.12.2
- MCP (coderpack) 9.19
- Forge 14.21.1
- chicken chunk 2.4.1.71
- CC 1.80 pr1
- Build computer, and start it by right clicking then:

https://pasteboard.co/HnSwNkY.png
if i go back to craft os i have the folowing:

https://pasteboard.co/HnSxrAS.png
If i edit the test.txt with "edit test.txt" nothing is inside the file
Can someone help me please
- ComputerCraft | Programmable Computers for Minecraft
- → Zepate's Content


