SHOW:
|
|
- or go back to the newest paste.
| 1 | --[[ | |
| 2 | 2013 (c) psychedelixx | |
| 3 | - | Minecraft Turtle: Room |
| 3 | + | Minecraft Turtle: Chest Tunnel |
| 4 | 2013-05-22 | |
| 5 | ||
| 6 | Digs a room with specified dimensions. | |
| 7 | ||
| 8 | Usage: | |
| 9 | - use turtle and type "label set <name>" | |
| 10 | (to give your turtle an unique name so it remembers its programs) | |
| 11 | - | - type "pastebin get tPQVZfmw room" |
| 11 | + | - type "pastebin get YijBG3sz ctunnel " |
| 12 | - | - type "room <width> [<length>] [<height>]" |
| 12 | + | - type "ctunnel <length> [<return (0|1)>]" |
| 13 | - | - default length = width |
| 13 | + | - place chests in slot 15 |
| 14 | - | - default height = 2 |
| 14 | + | - place torches in slot 16 |
| 15 | - | - place solid blocks in slot 16 to fill the ground |
| 15 | + | |
| 16 | ||
| 17 | i = 0 | |
| 18 | ret = 0 | |
| 19 | ||
| 20 | function move() | |
| 21 | i = i+1 | |
| 22 | - | if fillGround and not turtle.detectDown() then |
| 22 | + | |
| 23 | turtle.refuel() | |
| 24 | - | turtle.placeDown() |
| 24 | + | |
| 25 | ||
| 26 | print("----------------")
| |
| 27 | print("Remaining fuel: " .. turtle.getFuelLevel())
| |
| 28 | print("Digged: " .. i .. "/" .. length .. "(" .. math.floor(100/length*i) .. "%)")
| |
| 29 | print("Next torch in " .. 9-i%8)
| |
| 30 | print("Next chest in " .. 33-i%32)
| |
| 31 | - | turtle.digUp() |
| 31 | + | |
| 32 | - | until not turtle.detectUp() |
| 32 | + | |
| 33 | --[[ Vorwärts graben und bewegen ]]-- | |
| 34 | while not turtle.forward() do | |
| 35 | turtle.dig() | |
| 36 | end | |
| 37 | ||
| 38 | - | print("Usage: room <width> [<length>] [<height>]")
|
| 38 | + | --[[ Hoch bzw. runter graben ]]-- |
| 39 | - | print("# default length = width")
|
| 39 | + | if i%2 == 1 then |
| 40 | - | print("# default height = 2")
|
| 40 | + | repeat |
| 41 | - | print("# place solid blocks in slot 16 to fill the ground")
|
| 41 | + | |
| 42 | until not turtle.detectUp() | |
| 43 | else | |
| 44 | turtle.digDown() | |
| 45 | end | |
| 46 | ||
| 47 | - | width = tonumber(args[1]) |
| 47 | + | --[[ Links graben ]]-- |
| 48 | - | length = width |
| 48 | + | turtle.turnLeft() |
| 49 | - | height = 2 |
| 49 | + | |
| 50 | - | fillGround = true |
| 50 | + | |
| 51 | until not turtle.detect() | |
| 52 | - | if #args >= 2 then |
| 52 | + | |
| 53 | - | length = tonumber(args[2]) |
| 53 | + | --[[ Chest setzen und Items ablegen ]]-- |
| 54 | if i%32 == 1 and i > 5 then | |
| 55 | - | if #args == 3 then |
| 55 | + | turtle.select(15) |
| 56 | - | height = tonumber(args[3]) |
| 56 | + | turtle.place() |
| 57 | for slot = 1, 14 do | |
| 58 | turtle.select(slot) | |
| 59 | - | if height*width*length < 1 then |
| 59 | + | turtle.drop() |
| 60 | - | print( "A room must be at least 1m^3." ) |
| 60 | + | |
| 61 | - | error() |
| 61 | + | |
| 62 | ||
| 63 | --[[ Rechts graben ]]-- | |
| 64 | turtle.turnLeft() | |
| 65 | turtle.turnLeft() | |
| 66 | repeat | |
| 67 | turtle.dig() | |
| 68 | until not turtle.detect() | |
| 69 | ||
| 70 | --[[ Fackel setzen ]]-- | |
| 71 | if i%8 == 1 then | |
| 72 | turtle.select(16) | |
| 73 | - | print("Digging " .. width .. "*" .. length .. "*" .. height .. " (w*l*h)")
|
| 73 | + | turtle.place() |
| 74 | end | |
| 75 | ||
| 76 | - | nextTurnRight = true |
| 76 | + | --[[ Hoch bzw. runter bewegen ]]-- |
| 77 | - | h = 0 |
| 77 | + | if i%2 == 1 then |
| 78 | turtle.digDown() | |
| 79 | turtle.up() | |
| 80 | - | w = 1 |
| 80 | + | repeat |
| 81 | - | while w <= width do |
| 81 | + | |
| 82 | - | print("")
|
| 82 | + | until not turtle.detectUp() |
| 83 | - | if turtle.getFuelLevel() ~= "unlimited" then |
| 83 | + | else |
| 84 | - | print("Fuel: " .. turtle.getFuelLevel())
|
| 84 | + | repeat |
| 85 | - | end |
| 85 | + | |
| 86 | - | for l = 1, length-1 do |
| 86 | + | until not turtle.detectUp() |
| 87 | - | move() |
| 87 | + | |
| 88 | - | end |
| 88 | + | turtle.digDown() |
| 89 | - | if w < width then |
| 89 | + | |
| 90 | - | if nextTurnRight then |
| 90 | + | |
| 91 | - | turtle.turnRight() |
| 91 | + | --[[ Rechts graben ]]-- |
| 92 | - | move() |
| 92 | + | |
| 93 | - | turtle.turnRight() |
| 93 | + | |
| 94 | - | nextTurnRight = false |
| 94 | + | until not turtle.detect() |
| 95 | - | else |
| 95 | + | |
| 96 | - | turtle.turnLeft() |
| 96 | + | --[[ Links graben ]]-- |
| 97 | - | move() |
| 97 | + | turtle.turnLeft() |
| 98 | - | turtle.turnLeft() |
| 98 | + | turtle.turnLeft() |
| 99 | - | nextTurnRight = true |
| 99 | + | |
| 100 | - | end |
| 100 | + | |
| 101 | - | end |
| 101 | + | until not turtle.detect() |
| 102 | - | w = w+1 |
| 102 | + | |
| 103 | - | end |
| 103 | + | --[[ Nach vorne drehen ]]-- |
| 104 | - | if h < height-1 then |
| 104 | + | turtle.turnRight() |
| 105 | - | h = h+2 |
| 105 | + | |
| 106 | - | else |
| 106 | + | |
| 107 | - | if h == height-1 then |
| 107 | + | |
| 108 | - | h = h+1 |
| 108 | + | |
| 109 | - | end |
| 109 | + | |
| 110 | print("ctunnel <length> [<return (0|1)>]")
| |
| 111 | - | |
| 111 | + | print("place chests in slot 15")
|
| 112 | - | if h < height then |
| 112 | + | print("place torches in slot 16")
|
| 113 | - | turtle.turnRight() |
| 113 | + | |
| 114 | - | turtle.turnRight() |
| 114 | + | |
| 115 | - | turtle.up() |
| 115 | + | |
| 116 | end | |
| 117 | - | if h < height-1 then |
| 117 | + | |
| 118 | - | turtle.up() |
| 118 | + | length = tonumber(args[1]) |
| 119 | - | turtle.digUp() |
| 119 | + | |
| 120 | - | end |
| 120 | + | if #args == 2 then |
| 121 | ret = 1 | |
| 122 | - | fillGround = false |
| 122 | + | |
| 123 | - | until h >= height |
| 123 | + | |
| 124 | if turtle.getFuelLevel() == 0 then | |
| 125 | - | while h > 2 do |
| 125 | + | |
| 126 | end | |
| 127 | - | h = h-1 |
| 127 | + | |
| 128 | if turtle.getFuelLevel() == 0 then | |
| 129 | print("I need fuel!")
| |
| 130 | else | |
| 131 | print("======== 2013 (c) psychedelixx ========")
| |
| 132 | print("Let's go!")
| |
| 133 | print("Digging " .. length)
| |
| 134 | move() | |
| 135 | ||
| 136 | print("")
| |
| 137 | print("Fuel: " .. turtle.getFuelLevel())
| |
| 138 | ||
| 139 | for l = 1, length-1 do | |
| 140 | move() | |
| 141 | end | |
| 142 | ||
| 143 | if ret == 1 then | |
| 144 | turtle.turnLeft() | |
| 145 | turtle.turnLeft() | |
| 146 | while i > 0 do | |
| 147 | turtle.forward() | |
| 148 | i = i-1 | |
| 149 | end | |
| 150 | end | |
| 151 | end |