daily pastebin goal
87%
SHARE
TWEET

rtl

a guest Jan 19th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Kopirajt 2019 janek222
  2.  
  3. if fs.exists("rtl_data") then
  4. local rtl_h = fs.open("rtl_data","r")
  5. rtl = textutils.unserialise(rtl_h.readAll())
  6. rtl_h.close()
  7. else
  8. rtl = {working=false,idle=false,data={}}
  9. end
  10.  
  11. function save()
  12. local rtl_h = fs.open("rtl_data","w")
  13. rtl_h.write(textutils.serialise(rtl))
  14. rtl_h.close()
  15. end
  16.  
  17. funcs = {
  18. oldf = turtle.forward,
  19. oldb = turtle.back,
  20. oldu = turtle.up,
  21. oldd = turtle.down,
  22. oldl = turtle.turnLeft,
  23. oldr = turtle.turnRight,
  24. oldp = turtle.placeDown,
  25. oldbr = turtle.digDown,
  26. }
  27. funcs.oldf = function()
  28. if not funcs.oldf() then
  29. turtle.dig()
  30. funcs.oldf()
  31. end
  32. end
  33. funcs.oldb = function()
  34. if not funcs.oldb() then
  35. turtle.turnLeft()
  36. turtle.turnLeft()
  37. turtle.dig()
  38. turtle.turnRight()
  39. turtle.turnRight()
  40. end
  41. end
  42. funcs.oldu = function()
  43. if not funcs.oldu() then
  44. turtle.digUp()
  45. funcs.oldu()
  46. end
  47. end
  48. funcs.oldd = function()
  49. if not funcs.oldd() then
  50. turtle.digDown()
  51. funcs.oldd()
  52. end
  53. end
  54.  
  55. turtle.setWorking = function(working)
  56. rtl.working = working
  57. save()
  58. end
  59.  
  60. turtle.setIdle = function(idle)
  61. rtl.idle = idle
  62. save()
  63. end
  64.  
  65. turtle.isIdle = function()
  66. return rtl.idle
  67. end
  68.  
  69. turtle.forward = function()
  70. table.insert(rtl.data,"b")
  71. funcs.oldf()
  72. save()
  73. end
  74.  
  75. turtle.back = function()
  76. table.insert(rtl.data,"f")
  77. funcs.oldb()
  78. save()
  79. end
  80.  
  81. turtle.up = function()
  82. table.insert(rtl.data,"d")
  83. funcs.oldu()
  84. save()
  85. end
  86.  
  87. turtle.down = function()
  88. table.insert(rtl.data,"u")
  89. funcs.oldd()
  90. save()
  91. end
  92.  
  93. turtle.turnRight = function()
  94. table.insert(rtl.data,"l")
  95. funcs.oldr()
  96. save()
  97. end
  98.  
  99. turtle.turnLeft = function()
  100. table.insert(rtl.data,"r")
  101. funcs.oldl()
  102. save()
  103. end
  104.  
  105. turtle.placeDown = function()
  106. table.insert(rtl.data,"br")
  107. funcs.oldp()
  108. save()
  109. end
  110.  
  111. turtle.rtl = function()
  112. for i=1,#rtl.data do
  113. local act = table.remove(rtl.data,#rtl.data)
  114. funcs["old"..act]()
  115. end
  116. end
  117.  
  118. turtle.isWorking = function()
  119. return rtl.working
  120. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top