Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- turtleAdapter = {
- forward = function()
- while not turtle.forward() do
- if not turtle.dig() then
- turtle.attack()
- end
- end
- if test then
- if storageData.direction == 0 then
- storageData.pos[1] = storageData.pos[1] + 1
- elseif storageData.direction == 1 then
- storageData.pos[3] = storageData.pos[3] + 1
- elseif storageData.direction == 2 then
- storageData.pos[1] = storageData.pos[1] - 1
- elseif storageData.direction == 3 then
- storageData.pos[3] = storageData.pos[3] - 1
- end
- state = true
- end
- return true
- end,
- up = function()
- while not turtle.up() do
- if not turtle.digUp() then
- turtle.attackUp()
- end
- end
- if test then
- storageData.pos[2] = storageData.pos[2] + 1
- end
- return true
- end,
- down = function()
- while not turtle.down() do
- if not turtle.digDown() then
- turtle.attackDown()
- end
- end
- if test then
- storageData.pos[2] = storageData.pos[2] - 1
- end
- return true
- end,
- turnLeft = function()
- local state = turtle.turnLeft()
- storageData.direction = storageData.direction - 1
- if storageData.direction < 0 then
- storageData.direction = storageData.direction + 4
- end
- return state
- end,
- turnRight = function()
- local state = turtle.turnRight()
- storageData.direction = storageData.direction + 1
- if storageData.direction > 3 then
- storageData.direction = storageData.direction - 4
- end
- return state
- end,
- detect = function()
- return turtle.detect()
- end,
- detectUp = function()
- return turtle.detectUp()
- end,
- detectDown = function()
- return turtle.detectDown()
- end,
- select = function(id)
- return turtle.select(id)
- end,
- place = function()
- local state = turtle.place()
- if state then
- sleep(0.1)
- end
- return state
- end,
- placeUp = function()
- local state = turtle.placeUp()
- if state then
- sleep(0.1)
- end
- return state
- end,
- placeDown = function()
- local state = turtle.placeDown()
- if state then
- sleep(0.1)
- end
- return state
- end,
- dig = function()
- local digged = false;
- while (turtle.detect()) do
- if not turtle.dig() then
- break ;
- end
- digged = true;
- end
- return digged
- end,
- digUp = function()
- local digged = false;
- while (turtle.detectUp()) do
- if not turtle.digUp() then
- break ;
- end
- digged = true;
- end
- return digged
- end,
- digDown = function()
- local digged = false;
- while (turtle.detectDown()) do
- if not turtle.digDown() then
- break ;
- end
- digged = true;
- end
- return digged
- end,
- attack = function()
- return turtle.attack()
- end,
- attackUp = function()
- return turtle.attackUp()
- end,
- attackDown = function()
- return turtle.attackDown()
- end,
- getItemName = function(id)
- local name = turtle.getItemDetail(id)
- if name == nil then
- return nil
- end
- return name.name
- end,
- getItemCount = function(id)
- if id == nil then
- return turtle.getItemCount()
- end
- return turtle.getItemCount(id)
- end,
- getItemSpace = function(id)
- if id == nil then
- return turtle.getItemSpace()
- end
- return turtle.getItemSpace(id)
- end,
- drop = function(cnt)
- return turtle.drop(cnt)
- end,
- dropUp = function(cnt)
- return turtle.dropUp(cnt)
- end,
- dropDown = function(cnt)
- return turtle.dropDown(cnt)
- end,
- suck = function(cnt)
- return turtle.suck(cnt)
- end,
- suckUp = function(cnt)
- return turtle.suckUp(cnt)
- end,
- suckDown = function(cnt)
- return turtle.suckDown(cnt)
- end,
- refuel = function()
- return turtle.refuel()
- end,
- getFuelLevel = function()
- return turtle.getFuelLevel()
- end
- }
- function setStorageData(sD)
- storageData = sD
- end
- return {
- turtleAdapter = turtleAdapter, setStorageData = setStorageData,
- setTest = function(t)
- test = t
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement