Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Slot 1 Block = Smooth Stone
- -- Slot 2 Block = Cobble
- -- Slot 3 Block = Thickened Glass
- modem = peripheral.wrap("right")
- face = 1 -- intial facing direction
- xFreq = 1
- yFreq = 2
- zFreq = 3
- Action = 4
- modem.open(xFreq)
- modem.open(yFreq)
- modem.open(zFreq)
- modem.open(Action)
- structure = Taurus -- place your array name here
- baseDirection = "North"
- yTravel = 120
- xPos = nil
- yPos = nil
- zPos = nil
- xHome = nil
- yHome = nil
- zHome = nil
- xProgress = nil
- yProgress = nil
- zProgress = nil
- fProgress = nil
- yMin = 82
- xQuarry = nil
- yQuarry = nil
- zQuarry = nil
- xSlot1 = 2939
- ySlot1 = 96
- zSlot1 = 1860
- xSlot2 = 2936
- ySlot2 = 96
- zSlot2 = 1860
- xSlot3 = 2933
- ySlot3 = 96
- zSlot3 = 1860
- slot = 1
- row = 1
- directions = {"North","East","South","West"}
- baseDirection = "North""Not Calibrated")
- end
- end
- function digForward()
- while turtle.detect() do
- turtle.dig()
- end
- travelForward()
- if inventoryFull() then
- returnItems()
- end
- end
- function travelBack()
- turtle.back()
- if cal == true then
- if face == 1 then
- zPos = zPos + 1
- elseif face == 2 then
- xPos = xPos - 1
- elseif face == 3 then
- zPos = zPos - 1
- elseif face == 4 then
- xPos = xPos + 1
- end
- else
- print("Not Calibrated")
- end
- end
- function travelUp()
- turtle.up()
- if cal == true then
- yPos = yPos + 1
- else
- print("Not Calibrated")
- end
- end
- function travelDown()
- turtle.down()
- if cal == true then
- yPos = yPos - 1
- else
- print("Not Calibrated")
- end
- if yPos < yMin then
- yMin = yPos
- end
- end
- function digDown()
- while turtle.detectDown() do
- turtle.digDown()
- end
- travelDown()
- end
- function Look(direction)
- while direction ~= directions[face] do
- Right()
- end
- end
- function goto(xTarget, yTarget, zTarget)
- if xTarget < xPos then
- Look("West")
- while xTarget < xPos do
- travelForward()
- end
- end
- if xTarget > xPos then
- Look("East")
- while xTarget > xPos do
- travelForward()
- end
- end
- if zTarget < zPos then
- Look("North")
- while zTarget < zPos do
- travelForward()
- end
- end
- if zTarget > zPos then
- Look("South")
- while zTarget > zPos do
- travelForward()
- end
- end
- while yTarget < yPos do
- travelDown()
- end
- while yTarget > yPos do
- travelUp()
- end
- end
- function Fuel()
- redstone.setOutput("back", true)
- turtle.refuel()
- turtle.dropDown()
- redstone.setOutput("back", false)
- print(turtle.getFuelLevel())
- sleep(0.5)
- end
- function returnItems(xReturn,yReturn,zReturn,slot)
- xProgress = xPos
- yProgress = yPos
- zProgress = zPos
- fProgress = face
- goto(xPos,yTravel,zPos)
- goto(xReturn,yReturn,zReturn)
- if slot == 1 then
- for i = 1,4 do
- turtle.select(i)
- turtle.dropDown()
- turtle.suckDown()
- end
- elseif slot == 2 then
- for i = 5,8 do
- turtle.select(i)
- turtle.dropDown()
- turtle.suckDown()
- end
- elseif slot == 3 then
- for i = 9,16 do
- turtle.select(i)
- turtle.dropDown()
- turtle.suckDown()
- end
- end
- Full = 0
- goto(xProgress,yProgress,zProgress)
- Look(directions[fProgress])
- end
- function Launch()
- goto(xSlot1,ySlot1,zSlot1)
- for i = 1,4 do
- turtle.select(i)
- turtle.dropDown()
- turtle.suckDown(64)
- end
- goto(xSlot2,ySlot2,zSlot2)
- for i = 5,8 do
- turtle.select(i)
- turtle.dropDown()
- turtle.suckDown(64)
- end
- goto(xSlot3,ySlot3,zSlot3)
- for i = 9,16 do
- turtle.select(i)
- turtle.dropDown()
- turtle.suckDown(64)
- end
- slot = 1
- goto(xPos, yTravel, zPos)
- end
- function Dock()
- Look(baseDirection)
- for a = 1,16 do
- turtle.select(a)
- turtle.dropDown()
- end
- turtle.select(1)
- end
- -- keeps the selection an a full inventory slot
- -- and refills when empty
- function checkInventory(a)
- if a == 1 then
- if turtle.getItemCount(1) > 0 then
- turtle.select(1)
- elseif turtle.getItemCount(2) > 0 then
- turtle.select(2)
- elseif turtle.getItemCount(3) > 0 then
- turtle.select(3)
- elseif turtle.getItemCount(4) > 0 then
- turtle.select(4)
- else
- returnItems(xSlot1,ySlot1,zSlot1,a)
- end
- elseif a == 2 then
- if turtle.getItemCount(5) > 0 then
- turtle.select(5)
- elseif turtle.getItemCount(6) > 0 then
- turtle.select(6)
- elseif turtle.getItemCount(7) > 0 then
- turtle.select(7)
- elseif turtle.getItemCount(8) > 0 then
- turtle.select(8)
- else
- returnItems(xSlot2,ySlot2,zSlot2,a)
- end
- elseif a == 3 then
- if turtle.getItemCount(9) > 0 then
- turtle.select(9)
- elseif turtle.getItemCount(10) > 0 then
- turtle.select(10)
- elseif turtle.getItemCount(11) > 0 then
- turtle.select(11)
- elseif turtle.getItemCount(12) > 0 then
- turtle.select(12)
- elseif turtle.getItemCount(13) > 0 then
- turtle.select(13)
- elseif turtle.getItemCount(14) > 0 then
- turtle.select(14)
- elseif turtle.getItemCount(15) > 0 then
- turtle.select(15)
- elseif turtle.getItemCount(16) > 0 then
- turtle.select(16)
- else
- returnItems(xSlot3,ySlot3,zSlot3,a)
- end
- end
- end
- -- places a block and moves forward
- function Place(a)
- checkInventory(a)
- if turtle.detectDown() ~= true then
- turtle.placeDown()
- travelForward()
- else
- travelForward()
- end
- end
- function row1() -- turns turtle around and keeps rows even
- Right()
- travelForward()
- Right()
- travelForward()
- end
- function row2() -- turns turtle around and keeps rows even
- Left()
- travelForward()
- Left()
- travelForward()
- end
- function newLayer() -- takes turtle up a level and starts a new layer
- if row == 2 then
- travelUp()
- Right()
- travelForward()
- Left()
- elseif row == 1 then
- travelUp()
- Left()
- travelForward()
- Right()
- end
- end
- -- reads your arrays and tells the turtle what to do with the information
- function bluePrint(a)
- for b,c in pairs(a) do
- for k,block in pairs(a[b]) do
- if block == 0 then
- travelForward()
- else
- Place(block)
- end
- end
- if row == 1 then
- row1()
- row = 2
- elseif row == 2 then
- row2()
- row = 1
- end
- end
- newLayer()
- row = 1
- end
- while true do
- event, side, sent, reply, message, distance = os.pullEvent("modem_message")
- if sent == xFreq then
- xQuarry = message
- end
- if sent == yFreq then
- yQuarry = message
- end
- if sent == zFreq then
- zQuarry = message
- end
- if sent == Action and message == "Go" then
- setLocation()
- print(getLocation())
- Launch()
- goto(xQuarry,yQuarry,zQuarry)
- for m,n in pairs (Taurus) do
- bluePrint(Taurus[m])
- end
- goto(xHome, yHome, zHome)
- Dock()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement