Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This is part of a Computercraft Programming Teaching Program
- tSides = {"left","right","bottom","top","front","back"}
- for i = 1, #tSides do
- monitor = peripheral.wrap(tSides[i])
- if monitor then
- side = tSides[i]
- break
- end
- end
- --Prevents program termination
- os.pullEvent = os.pullEventRaw
- term.redirect(peripheral.wrap(side))
- -- Resets Screen
- function reset()
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- end
- reset()
- print("Section 9 - File System \n ")
- print("These commands are used to edit/create/delete files on the computer from within the program.")
- print("Some uses for these can be record keeping, program config files, making a database, etc.")
- print(" ")
- print("file1 = fs.open(\"file\", \"a\") - uses \"file1\" as a handle for the file \"file\"")
- print("Notice the \"a\" at the end. That set the file mode to append. That means writing to the file will add onto it.")
- print("Other file modes are \"r\" - Read Only, and \"w\" - write. Write mode overwrites a file with new data.")
- print("fs.exists(\"<file path>\") - Returns a boolean value if the file exists or not. Can be used as a condition for loops and statements")
- print("if fs.exists(\"file\") == true then <--- Example Usage")
- print("file1.write(\"test\") - Writes \"test\" to the file \"file\"")
- print("file1.writeLine(\"test\") - Same as fs.write(), except it makes a new line after")
- print("Think of fs.write() as write() and fs.writeLine() as print()")
- term.restore()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement