daily pastebin goal
66%
SHARE
TWEET

rtl

a guest Jan 19th, 2019 66 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.  
  28.  
  29. turtle.setWorking = function(working)
  30. rtl.working = working
  31. save()
  32. end
  33.  
  34. turtle.setIdle = function(idle)
  35. rtl.idle = idle
  36. save()
  37. end
  38.  
  39. turtle.isIdle = function()
  40. return rtl.idle
  41. end
  42.  
  43. turtle.forward = function()
  44. table.insert(rtl.data,"b")
  45. funcs.oldf()
  46. save()
  47. end
  48.  
  49. turtle.back = function()
  50. table.insert(rtl.data,"f")
  51. funcs.oldb()
  52. save()
  53. end
  54.  
  55. turtle.up = function()
  56. table.insert(rtl.data,"d")
  57. funcs.oldu()
  58. save()
  59. end
  60.  
  61. turtle.down = function()
  62. table.insert(rtl.data,"u")
  63. funcs.oldd()
  64. save()
  65. end
  66.  
  67. turtle.turnRight = function()
  68. table.insert(rtl.data,"l")
  69. funcs.oldr()
  70. save()
  71. end
  72.  
  73. turtle.turnLeft = function()
  74. table.insert(rtl.data,"r")
  75. funcs.oldl()
  76. save()
  77. end
  78.  
  79. turtle.placeDown = function()
  80. table.insert(rtl.data,"br")
  81. funcs.oldp()
  82. save()
  83. end
  84.  
  85. turtle.rtl = function()
  86. for i=1,#rtl.data do
  87. local act = table.remove(rtl.data,#rtl.data)
  88. funcs["old"..act]()
  89. end
  90. end
  91.  
  92. turtle.isWorking = function()
  93. return rtl.working
  94. 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