SHOW:
|
|
- or go back to the newest paste.
| 1 | local t = turtle | |
| 2 | local error = 0 | |
| 3 | local pause = 0.5 | |
| 4 | ||
| 5 | function rotateBlock() | |
| 6 | rs.setOutput("left",true)
| |
| 7 | sleep(0.1) | |
| 8 | rs.setOutput("left",false)
| |
| 9 | os.pullEvent("redstone")
| |
| 10 | if(not rs.getInput("left")) then
| |
| 11 | print("Warning: wrong redstone signal received")
| |
| 12 | local signal = false | |
| 13 | while not signal do | |
| 14 | os.pullEvent("redstone")
| |
| 15 | signal = rs.getInput("left")
| |
| 16 | end | |
| 17 | print("Warning: correct redstone signal received after wrong signal")
| |
| 18 | end | |
| 19 | end | |
| 20 | ||
| 21 | function openDoor() | |
| 22 | t.select(2) | |
| 23 | if(t.getItemCount(2) > 0) then | |
| 24 | print("Error: ItemCount slot 2 > 0")
| |
| 25 | error = 11 | |
| 26 | return | |
| 27 | end | |
| 28 | rs.setOutput("top",true)
| |
| 29 | sleep(0.05) | |
| 30 | rs.setOutput("top",false)
| |
| 31 | if(t.getItemCount(2) == 0) then | |
| 32 | print("Error: ItemCount slot 2 == 0")
| |
| 33 | error = 12 | |
| 34 | return | |
| 35 | end | |
| 36 | if(not t.transferTo(3)) then | |
| 37 | print("Error: transfer to slot 3 failed")
| |
| 38 | error = 13 | |
| 39 | return | |
| 40 | end | |
| 41 | if(not t.digUp()) then | |
| 42 | print("Error: cannot break Block Breaker")
| |
| 43 | error = 21 | |
| 44 | return | |
| 45 | end | |
| 46 | t.select(1) | |
| 47 | if(not t.placeUp()) then | |
| 48 | print("Error: cannot place Auto Placer")
| |
| 49 | error = 22 | |
| 50 | return | |
| 51 | end | |
| 52 | if(t.getItemCount(1) < 1) then | |
| 53 | print("Error: less than one Auto Placer remaining")
| |
| 54 | error = 14 | |
| 55 | return | |
| 56 | end | |
| 57 | rotateBlock() | |
| 58 | t.select(3) | |
| 59 | if(t.getItemCount(3) < 3) then | |
| 60 | print("Error: less than three door blocks in slot 3")
| |
| 61 | error = 15 | |
| 62 | return | |
| 63 | end | |
| 64 | if(not t.dropUp(2)) then | |
| 65 | print("Error: cannot drop two items into Auto Placer")
| |
| 66 | error = 31 | |
| 67 | return | |
| 68 | end | |
| 69 | sleep(pause) | |
| 70 | end | |
| 71 | ||
| 72 | function closeDoor() | |
| 73 | t.select(3) | |
| 74 | local nDoorBlocks = t.getItemCount(3) | |
| 75 | if(nDoorBlocks < 1) then | |
| 76 | print("Error: less than one door block(s) in slot 3")
| |
| 77 | error = 16 | |
| 78 | return | |
| 79 | end | |
| 80 | if(not t.dropUp()) then | |
| 81 | print("Error: cannot drop items into Auto Placer")
| |
| 82 | error = 32 | |
| 83 | return | |
| 84 | end | |
| 85 | --wait for door to close | |
| 86 | sleep(pause * nDoorBlocks) | |
| 87 | t.select(1) | |
| 88 | local nPlacers = t.getItemCount(1) | |
| 89 | if(not t.digUp()) then | |
| 90 | print("Error: cannot break Auto Placer")
| |
| 91 | error = 23 | |
| 92 | return | |
| 93 | end | |
| 94 | if(t.getItemCount(1) ~= nPlacers + 1) then | |
| 95 | print("Error: inventory mix up; nPlacers = "..nPlacers)
| |
| 96 | error = 17 | |
| 97 | return | |
| 98 | end | |
| 99 | t.select(2) | |
| 100 | if(not t.placeUp()) then | |
| 101 | print("Error: cannot place Block Breaker")
| |
| 102 | error = 24 | |
| 103 | return | |
| 104 | end | |
| 105 | rotateBlock() | |
| 106 | end | |
| 107 | ||
| 108 | function consistencyCheck() | |
| 109 | ||
| 110 | end | |
| 111 | ||
| 112 | local open = false | |
| 113 | ||
| 114 | while error == 0 do | |
| 115 | os.pullEvent("redstone")
| |
| 116 | if(rs.getInput("back")) then
| |
| 117 | if(open) then | |
| 118 | closeDoor() | |
| 119 | open = false | |
| 120 | - | else then |
| 120 | + | else |
| 121 | openDoor() | |
| 122 | open = true | |
| 123 | end | |
| 124 | end | |
| 125 | end | |
| 126 | print("error code: "..error) |