Advertisement
1vannn

OreSortingTurtle

Jun 9th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. local pasteID = "http://pastebin.com/raw.php?i=7CKzmErC"
  2. debug = true
  3. pasteContent = http.get(pasteID)
  4. Paste = pasteContent.readAll()
  5. pasteContent.close()
  6. function update()
  7. file = fs.open("startup","r")
  8. contents = file.readAll()
  9. file.close()
  10. if (Paste ~= contents) then
  11. print("Updating program...")
  12. shell.run("delete","startup")
  13. wFile = fs.open("startup","w")
  14. wFile.write(Paste)
  15. wFile.close()
  16. sleep(1)
  17. os.reboot()
  18. end
  19. end
  20. function checkItem(slot)
  21. local data = turtle.getItemDetail(slot)
  22. print("checking slot ", slot)
  23. turtle.select(slot)
  24. if (data) then
  25. print(data.name)
  26. if (string.find(data.name,"ore")) then
  27. if (string.find(data.name,"toolbox") == false) then
  28. turtle.select(slot)
  29. turtle.turnRight()
  30. turtle.drop()
  31. turtle.turnLeft()
  32. else
  33. turtle.select(slot)
  34. turtle.turnLeft()
  35. turtle.drop()
  36. turtle.turnRight()
  37. end
  38. else
  39. turtle.select(slot)
  40. turtle.turnLeft()
  41. turtle.drop()
  42. turtle.turnRight()
  43. end
  44. end
  45. end
  46. update()
  47. while true do
  48. for i = 1,16 do
  49. checkItem(i)
  50. sleep(1)
  51. term.clear()
  52. term.setCursorPos(1,1)
  53. end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement