Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- iDebug = true
- slot = 2
- iPriority = 4
- local mov ={}
- mov.forwardSafe = function ()
- if slot == 1 then
- slot = 2
- end
- while turtle.detect() do
- turtle.dig()
- sleep(1)
- end
- run = 1
- while not turtle.compareDown() do
- if slot > 16 then
- run = run+1
- slot = 2
- end
- if run == 2 then
- debugPrint("OH NO OUT OF BLOCKS!",0)
- return
- end
- turtle.select(slot)
- slot=slot+1
- end
- slot=slot-1
- if slot == 1 then
- slot = 2
- end
- while not turtle.forward() do
- sleep(0.1)
- end
- return true
- end
- mov.forward = function ()
- while turtle.detect() do
- turtle.dig()
- sleep(1)
- end
- while not turtle.forward() do
- sleep(0.1)
- end
- return true
- end
- mov.back = function ()
- while not turtle.back() do
- sleep(0.1)
- end
- return true
- end
- mov.up = function ()
- while not turtle.up() do
- sleep(0.1)
- end
- return true
- end
- mov.down = function ()
- while not turtle.down() do
- sleep(0.1)
- end
- return true
- end
- mov.place = function ()
- while turtle.getItemCount(slot) < 1 do
- slot=slot+1
- if slot > 16 then
- debugPrint("Error: We ran out of blocks!",0)
- return false
- end
- end
- while not turtle.placeDown() do
- sleep(0.1)
- end
- return true
- end
- function checkNextItem()
- while turtle.getItemCount(slot) < 1 do
- slot=slot+1
- if slot > 16 then
- debugPrint("Error: We ran out of blocks!",0)
- return false
- end
- end
- turtle.select(slot)
- run = 1
- while not turtle.compareDown() do
- if slot > 16 then
- run = run+1
- slot = 2
- end
- if run == 2 then
- debugPrint("Error: No match blocks",0)
- return false
- end
- turtle.select(slot)
- slot=slot+1
- end
- return true
- end
- function goRestock(yPosition)
- if yPosition == 1 then
- turtle.turnLeft()
- for slot = 2,16 do
- turtle.select(slot)
- if not turtle.compareDown() then
- turtle.dropUp()
- turtle.suck()
- else
- turtle.suck()
- end
- end
- turtle.turnRight()
- end
- end
- function goHome (direction)
- if direction == "left" then
- turtle.turnLeft()
- for i = 1,x-1 do
- mov.forward()
- end
- turtle.turnRight()
- for i = 1,z-1 do
- mov.forward()
- end
- turtle.turnRight()
- end
- if direction == "right" then
- for i = 1,z do
- mov.forward()
- end
- turtle.turnRight()
- end
- end
- local tArgs = { ... }
- if #tArgs <= 2 then
- print "you're using it wrong!"
- return
- end
- x=tArgs[1]
- y=tArgs[2]
- z=tArgs[3]
- mov.detectBlock = function ()
- while turtle.detectDown() do
- if turtle.compareDown() then
- return false
- else
- return true
- end
- end
- end
- function debugPrint (mess,priority)
- if iDebug == true and priority <= iPriority then
- print(mess)
- end
- end
- function checkBlockCount ()
- iblocks = 0
- blocks = (x*2)+(z*2)
- for i = 2,16 do
- turtle.select(i)
- if turtle.compareDown() then
- iblocks = tonumber(iblocks)+tonumber(turtle.getItemCount(i))
- end
- end
- turtle.select(slot)
- if iblocks > blocks then
- return true
- else
- return false
- end
- end
- turtle.select(slot)
- while turtle.getItemCount(slot) < 1 do
- slot=slot+1
- if slot > 16 then
- debugPrint("Error: No blocks loaded",0)
- end
- end
- turtle.select(slot)
- debugPrint("Structure Size: "..x..","..y..","..z,1)
- direction = "right"
- for i =1,z do
- for i = 1,x do
- if turtle.detectDown() then
- if turtle.compareDown() then
- mov.forwardSafe()
- else
- turtle.digDown()
- mov.place()
- mov.forwardSafe()
- end
- else
- mov.place()
- mov.forwardSafe()
- end
- end
- mov.back()
- debugPrint(direction,2)
- if direction == "right" then
- turtle.turnRight()
- mov.forwardSafe()
- turtle.turnRight()
- direction = "left"
- else
- turtle.turnLeft()
- mov.forwardSafe()
- turtle.turnLeft()
- direction = "right"
- end
- end
- debugPrint("final: "..direction,2)
- if direction == "left" then
- turtle.turnRight()
- mov.forward()
- end
- if direction == "right" then
- turtle.turnLeft()
- end
- yPosition = 1
- if not checkBlockCount() then
- debugPrint("NEED MORE BLOCKS",1)
- debugPrint("Blocks loaded: "..iblocks,1)
- debugPrint("Blocks needed for next row: "..blocks,1)
- position = "start"
- goHome(direction)
- goRestock(1)
- else
- debugPrint("Blocks loaded: "..iblocks,1)
- debugPrint("Blocks needed for next row: "..blocks,1)
- debugPrint("WE ARE GOOD TO MOVE ON",0)
- position = "go"
- goHome(direction)
- end
- for i = 2,y-1 do
- turtle.select(slot)
- checkNextItem()
- mov.up()
- for i = 1,x do
- mov.place()
- mov.forwardSafe()
- end
- mov.back()
- turtle.turnRight()
- mov.forwardSafe()
- for i = 1,z-1 do
- mov.place()
- mov.forwardSafe()
- end
- mov.back()
- turtle.turnRight()
- mov.forwardSafe()
- for i = 1,x-1 do
- mov.place()
- mov.forwardSafe()
- end
- mov.back()
- turtle.turnRight()
- mov.forwardSafe()
- for i = 1,z-2 do
- mov.place()
- mov.forwardSafe()
- end
- turtle.turnRight()
- if not checkBlockCount() then
- debugPrint("NEED MORE BLOCKS",1)
- debugPrint("Blocks loaded: "..iblocks,1)
- debugPrint("Blocks needed for next row: "..blocks,1)
- position = "start"
- goRestock(1)
- else
- debugPrint("Blocks loaded: "..iblocks,1)
- debugPrint("Blocks needed for next row: "..blocks,1)
- debugPrint("WE ARE GOOD TO MOVE ON",0)
- position = "go"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement