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