Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --API interface for turtles.
- -----------------
- --FUEL COMMANDS--
- -----------------
- --refil fuel level
- function refil()
- if turtle.getFuelLevel() ~= "unlimited" then
- if turtle.getFuelLevel() <1 then
- for i=1,16 do
- turtle.select(i)
- if turtle.refuel(1) then
- return true
- end
- end
- print("cT.API_Error::NoFuelFound")
- print("R_Application Suspended")
- print("S_Add Fuel And Press <Any Key>")
- os.pullEvent("key")
- return false
- else
- return true
- end
- end
- end
- --------------------
- --TURNING COMMANDS--
- --------------------
- --Turning Left Command
- function tL(qty)
- if qty == nil then
- qty = 1
- end
- turtle.turnLeft()
- qty = qty -1
- if qty > 0 then
- tL(qty)
- end
- return true
- end
- --Turning Right Command
- function tR(qty)
- if qty == nil then
- qty = 1
- end
- turtle.turnRight()
- qty = qty -1
- if qty > 0 then
- tR(qty)
- end
- return true
- end
- -------------------
- --DIGING COMMANDS--
- ------------------
- --Dig Forwards Command
- function dF()
- turtle.dig()
- end
- --Dig UpwardsCommand
- function dU()
- turtle.digUp()
- end
- --Dig Forwards Command
- function dD()
- turtle.digDown()
- end
- --Dig Left Command
- function dL()
- tL(1)
- dF()
- tR(1)
- end
- --Dig Right Command
- function dR()
- tR(1)
- dF()
- tL(1)
- end
- --Dig Backwards Command
- function dB()
- tL(2)
- dF()
- tL(2)
- end
- ---------------------
- --MOVEMENT COMMANDS--
- ---------------------
- --Move Forward command
- function mF(blocks)
- if blocks == nil then
- blocks = 1
- end
- refil()
- if turtle.forward() then
- blocks = blocks - 1
- else
- dF()
- end
- if blocks > 0 then
- mF(blocks)
- end
- return true
- end
- --Move Backward command
- function mB(blocks)
- if blocks == nil then
- blocks = 1
- end
- refil()
- if turtle.back() then
- blocks = blocks - 1
- else
- dB()
- end
- if blocks > 0 then
- mB(blocks)
- end
- return true
- end
- --Move Left command
- function mL(blocks)
- if blocks == nil then
- blocks = 1
- end
- refil()
- tL()
- if turtle.forward() then
- blocks = blocks - 1
- else
- dL()
- end
- if blocks > 0 then
- mL(blocks)
- end
- return true
- end
- --Move Right command
- function mR(blocks)
- if blocks == nil then
- blocks = 1
- end
- refil()
- tR()
- if turtle.forward() then
- blocks = blocks - 1
- else
- dR()
- end
- if blocks > 0 then
- mR(blocks)
- end
- return true
- end
- --Move Up command
- function mU(blocks)
- if blocks == nil then
- blocks = 1
- end
- refil()
- if turtle.up() then
- blocks = blocks - 1
- else
- dU()
- end
- if blocks > 0 then
- mU(blocks)
- end
- return true
- end
- --Move Down command
- function mD(blocks)
- if blocks == nil then
- blocks = 1
- end
- refil()
- if turtle.down() then
- blocks = blocks - 1
- else
- dD()
- end
- if blocks > 0 then
- mD(blocks)
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement