Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- 2016 (c) psychedelixx
- Minecraft Spiralstairs (robust)
- 2016-10-14
- Mines a 3x3 spiral stairs (downwards)
- 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 hYABpV27 spiralstairs"
- - type "spiralstairs <removeCenter 0|1>"
- - place chests in slot 15
- - place torches in slot 16
- ]]
- chestSlot = 15
- torchSlot = 16
- centerRemoved = false
- function placeChestIfFull()
- empty = 0
- for slot = 1, 14 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.up()
- t.turnAround()
- t.dig()
- if turtle.getItemCount(chestSlot) == 0 then
- print("Please put chests in slot 15 and press enter to continue")
- read()
- end
- turtle.select(chestSlot)
- turtle.place()
- for slot = 1, 14 do
- turtle.select(slot)
- turtle.drop()
- end
- t.turnAround()
- t.down()
- end
- end
- local args = { ... }
- if #args ~= 1 then
- print("Usage: spiralstairs <removeCenter 0|1>")
- print("place chests in slot 15")
- print("place torches in slot 16")
- error()
- end
- if tonumber(args[1]) == 1 then
- removeCenter = true
- else
- removeCenter = false
- end
- function removeCenterIfNeeded(x)
- if x%2 == 1 and removeCenter and not centerRemoved then
- t.left()
- t.dig()
- t.right()
- centerRemoved = true
- end
- end
- function placeTorchIfNeeded(x)
- if (x+1)%14 == 0 and turtle.getItemCount(torchSlot) > 0 then
- oldSlot = turtle.getSelectedSlot()
- t.right()
- t.place(torchSlot)
- t.left()
- turtle.select(oldSlot)
- end
- end
- print("======== 2016 (c) psychedelixx ========")
- print("Let's go!")
- print("Mining spiral stairs...")
- if turtle.getItemCount(chestSlot) == 0 then
- print("")
- print("Warning: no chests found in slot 15. Press enter to continue")
- read()
- end
- if turtle.getItemCount(torchSlot) == 0 then
- print("")
- print("Warning: no torches found in slot 16. Press enter to continue")
- read()
- end
- x = 0
- done = false
- t.digDown()
- t.down()
- repeat
- t.dig()
- placeChestIfFull()
- t.forward()
- x = x + 1
- removeCenterIfNeeded(x)
- placeTorchIfNeeded(x)
- if x%2 == 0 then
- t.left()
- end
- if x%7 == 0 then
- turtle.place()
- if turtle.detectDown() then
- if t.digDown() then
- placeChestIfFull()
- end
- end
- if not t.down() then
- done = true
- end
- centerRemoved = false
- end
- until done
Advertisement
Add Comment
Please, Sign In to add comment