Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local version = "3.0"
- function move(direction)
- if direction == "up" then
- while turtle.up() == false do
- turtle.digUp()
- turtle.attackUp()
- end
- elseif direction == "forward" then
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- end
- elseif direction == "down" then
- while turtle.down() == false do
- turtle.digDown()
- turtle.attackDown()
- end
- end
- end
- -- Force move up/forward/down with this function
- status = {move = 1,cube = 1}
- helpTable = {move = "move in any direction", cube = "mine out a cuboid in dimension arguments"}
- functionTable = {
- move = function(item,connectID,mProt)
- moveBlocks = tonumber(item[2])
- if moveBlocks == nil then
- moveBlocks = 0
- end
- if not tonumber(moveBlocks) then
- rednet.send(connectID, "Expected number as 3rd argument. Instead Received: " .. item[2], mProt)
- else
- function mover(direction)
- while moveBlocks > 0 do
- move(direction)
- moveBlocks = moveBlocks - 1
- end
- end
- if item[1] == "up" or item[1] == "down" or item[1] == "forward" or item[1] == "right" or item[1] == "left" or item[1] == "back" then
- if moveBlocks > 1 then
- rednet.send(connectID, "Moving " .. item[1] .. " " .. item[2] .. " blocks!", mProt)
- elseif moveBlocks == 1 then
- rednet.send(connectID, "Moving " .. item[1] .. " 1 block", mProt)
- else
- rednet.send(connectID, "Moving " .. item[1], mProt)
- end
- if item[1] == "right" then
- turtle.turnRight()
- item[1] = "forward"
- elseif item[1] == "left" then
- turtle.turnLeft()
- item[1] = "forward"
- elseif item[1] == "back" then
- for i=1,2 do turtle.turnRight() end
- item[1] = "forward"
- end
- mover(item[1])
- else
- rednet.send(connectID, 'List of possible directions: "up", "down", "right", "left", "forward", "back" ', mProt)
- end
- end
- end,
- cube = function(item,connectID,mProt)
- if item[1] ~= nil and item[2] ~= nil and item[3] ~= nil and tonumber(item[1]) and tonumber(item[2]) and tonumber(item[3]) and tonumber(item[1]) > 0 and tonumber(item[2]) > 0 and tonumber(item[3]) > 0 then
- for i=1,3 do
- item[i] = tonumber(item[i])
- end
- rednet.send(connectID, "Mining out a " .. item[1] .. " x " .. item[2] .. " x " .. item[3] .. " cuboid", mProt)
- local xDist = item[1]
- local yDist = item[2]
- local zDist = item[3]
- local i = 0
- local levelsMined = 0
- function checkBreak()
- if yDist - levelsMined > 1 then
- turtle.digUp()
- end
- if yDist - levelsMined > 2 then
- turtle.digDown()
- end
- end
- function line()
- for k=1,xDist-1 do
- move("forward")
- checkBreak()
- end
- end
- function nextLine(direction)
- direction()
- move("forward")
- checkBreak()
- direction()
- end
- function layer(level)
- if yDist - levelsMined > 2 then
- move("up")
- end
- checkBreak()
- line()
- if zDist%2 == 1 then
- level = 0
- end
- for j=1,zDist-1 do
- if (level+j)%2 == 1 then
- nextLine(turtle.turnRight)
- else
- nextLine(turtle.turnLeft)
- end
- line()
- end
- if yDist - levelsMined > 2 then
- levelsMined = levelsMined + 3
- elseif yDist - levelsMined > 1 then
- levelsMined = levelsMined + 2
- else
- levelsMined = levelsMined + 1
- end
- end
- move("forward")
- layer(0)
- local level = 0
- while yDist - levelsMined > 0 do
- for l=1,2 do move("up") end
- for l=1,2 do turtle.turnRight() end
- level = level + 1
- layer(level)
- end
- local rightTurns = 2
- if level%2 == 0 then
- if zDist%2 == 1 then
- for i=1,2 do turtle.turnRight() end
- for i=1,xDist-1 do move("forward") end
- end
- turtle.turnRight()
- for i=1,zDist-1 do move("forward") end
- rightTurns = 1
- end
- local yOffset = 2
- if yDist % 3 == 1 then yOffset = 1 end
- for i=1,yDist-yOffset do move("down") end
- for i=1,rightTurns do turtle.turnRight() end
- else
- rednet.send(connectID, "Invalid dimensions, use 3 numbers bigger than 0", mProt)
- end
- end
- }
Add Comment
Please, Sign In to add comment