SHOW:
|
|
- or go back to the newest paste.
| 1 | --pastebin get 2mvkUaWL startup | |
| 2 | - | local Y = 64 |
| 2 | + | |
| 3 | - | print("Mining client awake: Hello World!")
|
| 3 | + | |
| 4 | print("Tunnel Client Alive: Hello World!")
| |
| 5 | ||
| 6 | -- Setup wireless | |
| 7 | - | -- 5 Server -> Client |
| 7 | + | |
| 8 | - | -- 6 Client -> Server |
| 8 | + | -- 210 Server -> Client |
| 9 | - | modem.open(110) |
| 9 | + | -- 220 Client -> Server |
| 10 | - | modem.open(120) |
| 10 | + | modem.open(210) |
| 11 | - | print("Channel 110 and 120 are open")
|
| 11 | + | modem.open(220) |
| 12 | print("Channel 210 and 220 are open")
| |
| 13 | ||
| 14 | -- Setup receiving wireless messages | |
| 15 | function WaitForMessage(messageCompare) | |
| 16 | while true do | |
| 17 | local a,b,c,d,e,f = os.pullEvent("modem_message")
| |
| 18 | print("Message received: ")
| |
| 19 | print(e) | |
| 20 | if(e == messageCompare) then | |
| 21 | print("Message accepted")
| |
| 22 | break | |
| 23 | elseif (e == "_Empty") then | |
| 24 | return true | |
| 25 | end | |
| 26 | end | |
| 27 | return false | |
| 28 | - | modem.transmit(120, 110, message) |
| 28 | + | |
| 29 | ||
| 30 | -- Setup sending wireless messages | |
| 31 | - | -- Down shorthand |
| 31 | + | |
| 32 | - | function Down() |
| 32 | + | modem.transmit(220, 210, message) |
| 33 | - | while not turtle.down() do |
| 33 | + | |
| 34 | - | if turtle.detectDown() then turtle.digDown() end |
| 34 | + | |
| 35 | - | turtle.attackDown() |
| 35 | + | |
| 36 | function Forward() | |
| 37 | - | turtle.dig() |
| 37 | + | |
| 38 | if turtle.detect() then turtle.dig() end | |
| 39 | turtle.attack() | |
| 40 | - | -- Up shorthand |
| 40 | + | |
| 41 | - | function Up() |
| 41 | + | |
| 42 | - | while not turtle.up() do |
| 42 | + | |
| 43 | - | if turtle.detectUp() then turtle.digUp() end |
| 43 | + | --Empty shorthand |
| 44 | - | turtle.attackUp() |
| 44 | + | function Empty() |
| 45 | turtle.dig() | |
| 46 | - | turtle.dig() |
| 46 | + | turtle.select(1) |
| 47 | while not turtle.place() do | |
| 48 | turtle.dig() | |
| 49 | turtle.attack() | |
| 50 | end | |
| 51 | for i = 16,1,-1 do | |
| 52 | turtle.select(i) | |
| 53 | turtle.drop() | |
| 54 | end | |
| 55 | turtle.dig() | |
| 56 | end | |
| 57 | - | -- Bedrock shorthand |
| 57 | + | |
| 58 | - | function IsBedrock() |
| 58 | + | |
| 59 | - | local success, data = turtle.inspectDown() |
| 59 | + | |
| 60 | - | if success then |
| 60 | + | |
| 61 | - | return data.name == "minecraft:bedrock" |
| 61 | + | |
| 62 | - | else |
| 62 | + | |
| 63 | - | return false |
| 63 | + | |
| 64 | print("Ensuring ender chest is inside me...")
| |
| 65 | turtle.select(1) | |
| 66 | turtle.dig() | |
| 67 | ||
| 68 | print("Letting server know ready...")
| |
| 69 | SendMessage("_TurtleReadyToMine")
| |
| 70 | ||
| 71 | print("Waiting to begin")
| |
| 72 | WaitForMessage("_Begin")
| |
| 73 | - | -- Reset position |
| 73 | + | |
| 74 | - | print("Waiting for signal to reset Y")
|
| 74 | + | |
| 75 | - | WaitForMessage("_ResetY")
|
| 75 | + | |
| 76 | - | print("Resetting to y " .. tostring(Y))
|
| 76 | + | |
| 77 | empty = WaitForMessage("_StartNextCycle")
| |
| 78 | ||
| 79 | - | while not IsBedrock() do Down() end |
| 79 | + | if empty then Empty() end |
| 80 | - | for i=0, Y do Up() end |
| 80 | + | |
| 81 | print("Starting next cycle...")
| |
| 82 | Forward() | |
| 83 | print("Letting server know ready for next cycle...")
| |
| 84 | SendMessage("_ReadyForNextCycle")
| |
| 85 | print(">>")
| |
| 86 | print(">>")
| |
| 87 | print(">>")
| |
| 88 | - | -- Mine Routine |
| 88 | + | |
| 89 | - | function Mine() |
| 89 | + | |
| 90 | print("Goodbye >>")
| |
| 91 | read() |