oblinger

Turtle Info

Mar 19th, 2014
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. function getOwner()
  2. if fs.exists("owner.info") == false then
  3. repeat
  4. term.clear()
  5. term.setCursorPos(1,1)
  6.  
  7. io.write("Please Enter Owner Name: ")
  8. input = io.read()
  9.  
  10. ownerFile = fs.open("owner.info","w")
  11. ownerFile.write(input)
  12. ownerFile.close()
  13.  
  14. print("Owner Set To "..input)
  15. print("Is that correct? (y/n)")
  16. answ = io.read()
  17.  
  18. if answ == "y" then
  19. print("Okay!")
  20. elseif answ == "n" then
  21. ownerFile = fs.open("owner.info","w")
  22. ownerFile.write("")
  23. ownerFile.close()
  24. end
  25. until answ == "y"
  26. else
  27. ownerFile = fs.open("owner.info","r")
  28. line = ownerFile.readLine()
  29. ownerFile.close()
  30. return line
  31. end
  32. end
  33.  
  34. function getPos()
  35. x, y, z = gps.locate()
  36. term.write(x.." ")
  37. term.write(y.." ")
  38. term.write(z.." ")
  39. end
  40.  
  41.  
  42.  
  43. term.clear()
  44. term.setCursorPos(1,1)
  45.  
  46. print("Turtle Info")
  47. print("-----------")
  48. print("Name: "..os.getComputerLabel())
  49. print("ID Number: "..os.getComputerID())
  50. print("Fuel Level: "..turtle.getFuelLevel())
  51. print("Owner: "..getOwner())
  52.  
  53. term.write("Position: ")
  54. term.write(getPos())
Advertisement
Add Comment
Please, Sign In to add comment