Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Better turtle API by Eriyn
- -- Vars :
- t = {}
- local facing = 0
- local x = 0
- local y = 0
- local z = 0
- -- Functions :
- function t:tR()
- turtle.turnRight()
- facing = (facing + 1) % 4
- return facing
- end
- function t:tL()
- turtle.turnLeft()
- facing = facing - 1
- if facing < 0 then
- facing = 3
- end
- return facing
- end
- function t:up(fuelSlot)
- while turtle.up() == false do
- if turtle.detectUp() then
- turtle.digUp()
- elseif fuelSlot ~= nil then
- t.refuel(fuelSlot)
- elseif fuelSlot == nil or (fuelSlot < 1 or fuelSlot > 16) then
- print("NOPE")
- return
- else
- turtle.attackUp()
- end
- end
- y = y + 1
- end
- function t:down()
- if turtle.down() then
- y = y - 1
- end
- end
- function t:refuel(fuelSlot)
- lastSlot = turtle.getSelectedSlot()
- if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
- turtle.select(tonumber(fuelSlot))
- refueled = turtle.refuel(1)
- turtle.select(lastSlot)
- end
- return refueled
- end
- -- Getters & Setters :
- function t:getDir()
- return facing
- end
- function t:getX()
- return x
- end
- function t:getY()
- return y
- end
- function t:getZ()
- return z
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement