Advertisement
Guest User

list

a guest
Apr 9th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. print("enter filename")
  2. filename = read()
  3. --REMEMBER TO CLOSE FILE
  4. function openFile()
  5.   fs.makeDir("saves")
  6.   file = fs.open("saves/" .. filename, "r")
  7. end
  8.  
  9. function getLineCount()
  10.   openFile()
  11.   i = 0
  12.   while file.readLine() do
  13.     i = i + 1
  14.   end
  15.   file.close()
  16. end
  17.  
  18.  
  19.  
  20. mon = peripheral.wrap("left")
  21. mon.clear()
  22. mon.setCursorPos(1,1)
  23. mon.setTextScale(1)
  24. mon.write("currently displaying: " .. filename)
  25. getLineCount()
  26. openFile()
  27. mon.setCursorPos(1,2)
  28. b=2
  29. for x = 1,i do
  30.   l = file.readLine()
  31.   mon.write(l)
  32.   b = b+1
  33.   mon.setCursorPos(1,b)
  34. end
  35. file.close()
  36.  
  37. fs.makeDir("backup")
  38. newfile = fs.open("backup/" .. filename, "w")
  39. newfile.writeLine(filename)
  40. newfile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement