Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Advanced Turtle API
- ]]
- local lclx=0
- local lcly=0
- local lclz=0;
- local _tf,_tu,_td,_tb,_ttl,_ttr
- local fx=1
- local fz=0
- function override()
- _tf=turtle.forward
- turtle.forward=aForw
- _tb=turtle.back
- turtle.back=aBack
- _tu=turtle.up
- turtle.up=aUp
- _td=turtle.down
- turtle.down=aDown
- _ttl=turtle.turnLeft
- turtle.turnLeft=aTurnL
- _ttr=turtle.turnRight
- turtle.turnRight=aTurnR
- end
- function unoverride()
- turtle.forward=_tf
- turtle.back=_tb
- turtle.up=_tu
- turtle.down=_td
- turtle.turnLeft=_ttl
- turtle.turnRight=_ttr
- end
- function aTurnR()
- _ttr()
- if fx==1 then
- fx=0
- fz=1
- elseif fx==-1 then
- fx=0
- fz=-1
- elseif fz==1 then
- fx=-1
- fz=0
- else
- fx=1
- fz=0
- end
- end
- function aTurnL()
- _ttl()
- if fx==1 then
- fx=0
- fz=-1
- elseif fx==-1 then
- fx=0
- fz=1
- elseif fz==1 then
- fx=1
- fz=0
- else
- fx=-1
- fz=0
- end
- end
- function aForw()
- succ=_tf()
- if succ then
- lclx=lclx+fx
- lclz=lclz+fz
- end
- return succ
- end
- function aBack()
- succ=_tb()
- if succ then
- lclx=lclx-fx
- lclz=lclz-fz
- end
- return succ
- end
- function aUp()
- succ=_tu()
- if succ then
- lcly=lcly+1
- end
- return succ
- end
- function aDown()
- succ=_tu()
- if succ then
- lcly=lcly-1
- end
- return succ
- end
- function setZero()
- lclx=0
- lcly=0
- lclz=0
- fx=1
- fz=0
- end
- function saveState()
- end
- function localPos()
- return {lclx,lcly,lclz,fx,fz}
- end
Add Comment
Please, Sign In to add comment