Advertisement
Rolcam

Computercraft Tutorial - Section 9.1 - File System Cont

Jun 14th, 2021 (edited)
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | None | 0 0
  1. --This is part of a Computercraft Programming Teaching Program
  2.  
  3. tSides = {"left","right","bottom","top","front","back"}
  4.  
  5. for i = 1, #tSides do
  6.   monitor = peripheral.wrap(tSides[i])
  7.   if monitor then
  8.         side = tSides[i]
  9.         break
  10.   end
  11. end
  12. --Prevents program termination
  13. os.pullEvent = os.pullEventRaw
  14. term.redirect(peripheral.wrap(side))
  15.  
  16. -- Resets Screen
  17. function reset()
  18. term.setTextColor(colors.white)
  19. term.setBackgroundColor(colors.black)
  20. term.clear()
  21. term.setCursorPos(1,1)
  22. end
  23.    
  24. reset()
  25. print("Section 9.1 - File System Cont. \n ")
  26. print(" ")
  27. print("file1.readLine() - Reads the next line in the file (only works while in read mode)")
  28. print("file1.readAll() - Reads all the data in the file (only works while in read mode)")
  29. print("file1.flush() - Flushes the data to the file while keeping the handle open afterwards")
  30. print("This is mainly used for logging purposes")
  31. print("file1.close() - Closes the file handle")
  32. print("fs.move(\"file\", \"docs/file2\") - Moves the file \"file\" to the directory \"docs\" with the file name of \"file2\"")
  33. print("fs.copy(\"file\", \"docs/file2\") - Same as fs.move(), except it copies the program to the new location instead")
  34. print("fs.delete(\"file\") - Deletes the file \"file\"")
  35. term.restore()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement