SHOW:
|
|
- or go back to the newest paste.
| 1 | os.loadAPI("move")
| |
| 2 | ||
| 3 | -- Functions -- | |
| 4 | ||
| 5 | function reset() | |
| 6 | move.reset() | |
| 7 | move.store("initialize", "false")
| |
| 8 | end | |
| 9 | ||
| 10 | function dig() | |
| 11 | while turtle.detect() do | |
| 12 | turtle.dig() | |
| 13 | end | |
| 14 | while turtle.detectDown() do | |
| 15 | turtle.digDown() | |
| 16 | end | |
| 17 | while turtle.detectUp() do | |
| 18 | turtle.digUp() | |
| 19 | sleep(0.6) | |
| 20 | end | |
| 21 | end | |
| 22 | ||
| 23 | function getType(number) | |
| 24 | if bit.band(number,1) == 0 then | |
| 25 | return "even" | |
| 26 | end | |
| 27 | return "odd" | |
| 28 | end | |
| 29 | ||
| 30 | function sweepLeft() | |
| 31 | while tonumber(location["y"])%3 == 0 and tonumber(location["x"]) < tonumber(quarry["width"])-1 do | |
| 32 | move.face(3) | |
| 33 | dig() | |
| 34 | move.forward() | |
| 35 | location = move.pull("location")
| |
| 36 | end | |
| 37 | dig() | |
| 38 | end | |
| 39 | ||
| 40 | function sweepUp() | |
| 41 | while tonumber(location["y"]) < tonumber(quarry["height"]) do | |
| 42 | move.face(1) | |
| 43 | dig() | |
| 44 | move.up() | |
| 45 | location = move.pull("location")
| |
| 46 | if tonumber(location["y"])%3 == 0 then | |
| 47 | dig() | |
| 48 | move.forward() | |
| 49 | location = move.pull("location")
| |
| 50 | break | |
| 51 | end | |
| 52 | end | |
| 53 | end | |
| 54 | ||
| 55 | function sweepRight() | |
| 56 | while tonumber(location["x"]) > 0 do | |
| 57 | move.face(1) | |
| 58 | dig() | |
| 59 | move.forward() | |
| 60 | location = move.pull("location")
| |
| 61 | end | |
| 62 | dig() | |
| 63 | end | |
| 64 | ||
| 65 | -- Program -- | |
| 66 | ||
| 67 | if not fs.exists("data/initialize") then
| |
| 68 | handle = fs.open("data/initialize", "w")
| |
| 69 | handle.write("false")
| |
| 70 | handle.close() | |
| 71 | end | |
| 72 | ||
| 73 | handle = fs.open("data/initialize", "r")
| |
| 74 | local initialize = handle.readAll() | |
| 75 | ||
| 76 | if initialize == "true" then | |
| 77 | print("quarry already started")
| |
| 78 | else | |
| 79 | print("Quarry initializing now...")
| |
| 80 | ||
| 81 | reset() | |
| 82 | ||
| 83 | term.clear() | |
| 84 | term.setCursorPos(1,1) | |
| 85 | term.write("Welcome to tompy Mine")
| |
| 86 | ||
| 87 | local quarry = {}
| |
| 88 | ||
| 89 | - | |
| 89 | + | |
| 90 | term.write("Quarry Width: ")
| |
| 91 | quarry["width"] = read() | |
| 92 | ||
| 93 | term.setCursorPos(1,4) | |
| 94 | term.write("Quarry Height: ")
| |
| 95 | quarry["height"] = read() | |
| 96 | ||
| 97 | term.setCursorPos(1,5) | |
| 98 | term.write("Quarry Depth: ")
| |
| 99 | quarry["depth"] = read() | |
| 100 | ||
| 101 | move.store("quarry", quarry)
| |
| 102 | ||
| 103 | move.store("initialize", true)
| |
| 104 | ||
| 105 | local mineLocation = {x = 0, y = 0, z = 1}
| |
| 106 | move.store("mineLocation", mineLocation)
| |
| 107 | end | |
| 108 | ||
| 109 | - | dig() |
| 109 | + | |
| 110 | quarry = move.pull("quarry")
| |
| 111 | mineLocation = move.pull("mineLocation")
| |
| 112 | ||
| 113 | move.display() | |
| 114 | ||
| 115 | while tonumber(location["z"]) < tonumber(quarry["depth"]) + 1 do | |
| 116 | sweepLeft() | |
| 117 | sweepUp() | |
| 118 | sweepRight() | |
| 119 | sweepUp() | |
| 120 | end |