Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- currentx = 1
- currenty = 1
- currentz = 1
- lasty = 1
- local arg = {...}
- maxX = tonumber(arg[1])
- maxY = tonumber(arg[2])
- maxZ = tonumber(arg[3])
- print("Creando un cuadrado de (x: " .. maxX .." y: " .. maxY .." z: " ..maxZ .. ")")
- turtle.select(1)
- turtle.refuel()
- turtle.select(2)
- siding = 1
- currentSlot = 2
- auxSlot = 2
- function returndown()
- while(currenty ~= lasty)
- do
- turtle.down()
- currenty = currenty + 1
- end
- end
- function returnstart()
- print("Returning to startpoint...")
- if(siding == 1) then
- turtle.turnLeft()
- while (currentz > 1)
- do
- turtle.forward()
- currentz = currentz - 1
- end
- turtle.turnLeft()
- while (currentx > 1)
- do
- turtle.forward()
- currentx = currentx - 1
- end
- turtle.turnLeft()
- turtle.turnLeft()
- currentx = 1
- currentz = 1
- else
- turtle.turnRight()
- while (currentz > 1)
- do
- turtle.forward()
- currentz = currentz - 1
- end
- turtle.turnLeft()
- while (currentx > 1)
- do
- turtle.forward()
- currentx = currentx - 1
- end
- currentx = 1
- currentz = 1
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- while (currentx ~= maxX or currenty ~= maxY or currentz ~= maxZ)
- do
- print("Posición acutal (x: " .. currentx .. " y: " .. currenty .." z: " ..currentz..")")
- compareblocker = true
- while((not turtle.compare()) and compareblocker and turtle.detect())
- do
- print("checking slot: " .. auxSlot)
- turtle.select(auxSlot)
- if(turtle.getItemCount(auxSlot) == 0) then
- compareblocker = false
- else
- if (auxSlot < 16) then
- auxSlot = auxSlot + 1
- turtle.select(auxSlot)
- else
- returnstart()
- while(currenty > 1)
- do
- turtle.up()
- currenty = currenty - 1
- end
- turtle.turnLeft()
- turtle.turnLeft()
- auxSlot = 16
- while(auxSlot ~= 1)
- do
- turtle.select(auxSlot)
- turtle.drop()
- auxSlot = auxSlot -1
- end
- auxSlot = 2
- turtle.select(2)
- turtle.turnLeft()
- turtle.turnLeft()
- compareblocker = false
- returndown()
- end
- end
- end
- if (turtle.getItemCount(currentSlot) == 64) then
- if (currentSlot < 16) then
- currentSlot = currentSlot +1
- turtle.select(currentSlot)
- else
- returnstart()
- while(currenty > 1)
- do
- turtle.up()
- currenty = currenty -1
- end
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(16)
- while(currentSlot ~= 1)
- do
- turtle.drop()
- currentSlot = currentSlot -1
- turtle.select(currentSlot)
- end
- currentSlot = 2
- turtle.turnLeft()
- turtle.turnLeft()
- returndown()
- end
- elseif (turtle.getItemCount(1) < 5) then
- returnstart()
- while(currenty > 1)
- do
- turtle.up()
- currenty = currenty -1
- end
- turtle.turnLeft()
- turtle.select(1)
- turtle.refuel()
- turtle.suck(64 - turtle.getItemCount(1))
- turtle.turnRight()
- returndown()
- elseif (turtle.getFuelLevel() < 10) then
- turtle.select(1)
- turtle.refuel()
- elseif (currentx < maxX) then
- turtle.dig()
- turtle.forward()
- currentx = currentx + 1
- elseif (currentz < maxZ and currentx >= maxX) then
- currentx = 1
- currentz = currentz + 1
- if (siding == 1) then
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- siding = 2
- else
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- siding = 1
- end
- else
- if (currenty < maxY) then
- returnstart()
- currentx = 1
- currentz = 1
- currenty = currenty + 1
- lasty = currenty
- turtle.digDown()
- turtle.down()
- siding = 1
- end
- end
- auxSlot = 2
- end
- returnstart()
- while(currenty > 1)
- do
- turtle.up()
- currenty = currenty -1
- end
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(16)
- currentSlot = 16
- while(currentSlot ~= 1)
- do
- turtle.drop()
- currentSlot = currentSlot -1
- turtle.select(currentSlot)
- end
- turtle.turnLeft()
- turtle.turnLeft()
Advertisement
Add Comment
Please, Sign In to add comment