Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- 2015 (c) psychedelixx
- Minecraft Turtle: Spiral miner (Robust)
- 2015-01-04
- Mines in a spiralform (spin me right round baby) and stays on the level it started.
- Robust API:
- http://computercraft.info/wiki/Robust_Turtle_API
- Usage:
- - use turtle and type "label set <name>"
- (to give your turtle an unique name so it remembers its programs)
- - type "pastebin get 7Ckr8y7s spiral"
- - type "spiral <limit> [<fillGround 0|1 default 0> <factor default 1.5> <useTesseract 0|1 default 0>]"
- - place chests in slot 16
- ]]
- torchesAvailable = false
- chestsAvailable = false
- torchSlot = 15
- factor = 1.5
- useTesseract = false
- function move()
- slot = 1
- while not turtle.detectDown() and fillGround == 1 do
- turtle.select(slot)
- turtle.placeDown()
- if slot < 13 then
- slot = slot+1
- else
- print("no items to fill ground")
- fillGround = 0
- break
- end
- end
- t.dig()
- t.forward()
- t.digUp()
- empty = 0
- for slot = 1, 13 do
- if turtle.getItemCount(slot) == 0 then
- empty = 1
- break
- end
- end
- --[[ if turtle is full, turn around, place chest, move items into it, turn around and continue ]]--
- if empty == 0 then
- t.turnAround()
- if not chestsAvailable then
- print("Please put chests in slot 15 and press enter to continue")
- read()
- end
- turtle.select(14)
- turtle.place()
- for slot = 1, 13 do
- turtle.select(slot)
- turtle.drop()
- end
- if useTesseract then
- os.sleep(0.5)
- turtle.select(14)
- turtle.dig()
- end
- if turtle.getItemCount(14) > 0 then
- chestsAvailable = true
- else
- chestsAvailable = false
- end
- t.turnAround()
- end
- end
- local args = { ... }
- if #args < 1 then
- print("")
- print("spiral <limit> [<fillGround 0|1 default 0> <factor default 1.5> <useTesseract 0|1 default 0]")
- print("place chests/tesseract in slot 14")
- print("place torches in slots 15 and 16")
- error()
- end
- if #args >= 1 then
- limit = tonumber(args[1])
- fillGround = 0
- end
- if #args >= 2 then
- fillGround = tonumber(args[2])
- end
- if #args >= 3 then
- factor= tonumber(args[3])
- end
- if #args >= 4 then
- if tonumber(args[4]) > 0 then
- useTesseract = true
- else
- useTesseract = false
- end
- end
- if turtle.getFuelLevel() < 0.75*limit*limit + limit then
- print("I need " .. (0.75*limit*limit + limit) - turtle.getFuelLevel() .. " more fuel!")
- else
- print("======== 2015 (c) psychedelixx ========")
- print("Let's go!")
- print("Mining a spiral...")
- if turtle.getItemCount(15)+turtle.getItemCount(16) > 0 then
- torchesAvailable = true
- else
- print("")
- print("Warning: no torches found in slot 15 and 16. Press enter to continue")
- read()
- torchesAvailable = false
- end
- if turtle.getItemCount(14) > 0 then
- chestsAvailable = true
- else
- print("")
- print("Warning: no chests found in slot 14. Press enter to continue")
- read()
- chestsAvailable = false
- end
- if turtle.getItemCount(15) > 0 then
- torchesAvailable = true
- torchSlot = 15
- elseif turtle.getItemCount(16) > 0 then
- torchesAvailable = true
- torchSlot = 16
- else
- torchesAvailable = false
- end
- if turtle.getItemCount(14) > 0 then
- chestsAvailable = true
- else
- chestsAvailable = false
- end
- x = 0
- repeat
- x = x + 1
- y = math.ceil(x*factor)
- for i = 1, y do
- move()
- if i%7 == 0 and y-i > 5 and torchesAvailable and turtle.detectDown() then
- t.turnAround()
- turtle.select(torchSlot)
- turtle.place()
- t.turnAround()
- if torchSlot == 15 and turtle.getItemCount(torchSlot) == 0 then
- torchSlot = 16
- elseif torchSlot == 16 and turtle.getItemCount(torchSlot) == 0 then
- torchSlot = 15
- end
- if turtle.getItemCount(15) + turtle.getItemCount(16) > 0 then
- torchesAvailable = true
- else
- torchesAvailable = false
- end
- end
- end
- if torchesAvailable then
- t.dig()
- turtle.select(torchSlot)
- turtle.place()
- end
- t.right()
- print (y .. " / " .. limit .. "... fuel: " .. turtle.getFuelLevel())
- until y >= limit
- print("Done")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement