Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Kopirajt 2019 janek222
- if fs.exists("rtl_data") then
- local rtl_h = fs.open("rtl_data","r")
- rtl = textutils.unserialise(rtl_h.readAll())
- rtl_h.close()
- else
- rtl = {working=false,idle=false,data={}}
- end
- function save()
- local rtl_h = fs.open("rtl_data","w")
- rtl_h.write(textutils.serialise(rtl))
- rtl_h.close()
- end
- funcs = {
- oldf = turtle.forward,
- oldb = turtle.back,
- oldu = turtle.up,
- oldd = turtle.down,
- oldl = turtle.turnLeft,
- oldr = turtle.turnRight,
- oldp = turtle.placeDown,
- oldbr = turtle.digDown,
- }
- funcs.oldf = function()
- if not funcs.oldf() then
- turtle.dig()
- funcs.oldf()
- end
- end
- funcs.oldb = function()
- if not funcs.oldb() then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.dig()
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- funcs.oldu = function()
- if not funcs.oldu() then
- turtle.digUp()
- funcs.oldu()
- end
- end
- funcs.oldd = function()
- if not funcs.oldd() then
- turtle.digDown()
- funcs.oldd()
- end
- end
- turtle.setWorking = function(working)
- rtl.working = working
- save()
- end
- turtle.setIdle = function(idle)
- rtl.idle = idle
- save()
- end
- turtle.isIdle = function()
- return rtl.idle
- end
- turtle.forward = function()
- table.insert(rtl.data,"b")
- funcs.oldf()
- save()
- end
- turtle.back = function()
- table.insert(rtl.data,"f")
- funcs.oldb()
- save()
- end
- turtle.up = function()
- table.insert(rtl.data,"d")
- funcs.oldu()
- save()
- end
- turtle.down = function()
- table.insert(rtl.data,"u")
- funcs.oldd()
- save()
- end
- turtle.turnRight = function()
- table.insert(rtl.data,"l")
- funcs.oldr()
- save()
- end
- turtle.turnLeft = function()
- table.insert(rtl.data,"r")
- funcs.oldl()
- save()
- end
- turtle.placeDown = function()
- table.insert(rtl.data,"br")
- funcs.oldp()
- save()
- end
- turtle.rtl = function()
- for i=1,#rtl.data do
- local act = table.remove(rtl.data,#rtl.data)
- funcs["old"..act]()
- end
- end
- turtle.isWorking = function()
- return rtl.working
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement