Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- 2016 (c) psychedelixx
- Minecraft Spiralstairs (robust)
- 2016-10-14
- Mines a spiral stairs (downwards left)
- 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 0gCW6AMP spiralstairs"
- - type "spiralstairs <size>"
- - place stairs in slot 14
- - place chests in slot 15
- - place torches in slot 16
- ]]
- stairsSlot = 14
- chestSlot = 15
- torchSlot = 16
- function placeChestIfFull()
- 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.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, 13 do
- turtle.select(slot)
- turtle.drop()
- end
- t.turnAround()
- t.down()
- end
- end
- local args = { ... }
- if #args ~= 1 then
- print("Usage: spiralstairs <size>")
- print("place stairs in slot 14")
- print("place chests in slot 15")
- print("place torches in slot 16")
- error()
- end
- function placeTorchIfNeeded(x)
- if (x+1)%13 == 0 and turtle.getItemCount(torchSlot) > 0 then
- oldSlot = turtle.getSelectedSlot()
- t.left()
- t.place(torchSlot)
- t.right()
- 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
- repeat
- t.dig()
- t.forward()
- placeChestIfFull()
- t.digUp()
- t.up()
- t.placeDown(stairsSlot)
- x = x + 1
- placeTorchIfNeeded(x)
- if x%(tonumber(args[1])-1) == 0 then
- t.right()
- end
- until done
Add Comment
Please, Sign In to add comment