SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local modem = peripheral.wrap("back")
|
| 1 | + | local modemSide = "right" |
| 2 | - | local hystMem = 0 |
| 2 | + | local manaLevel = 10 |
| 3 | - | local limitLow = 50 |
| 3 | + | local manaReading = 0 |
| 4 | - | local limitHigh = 95 |
| 4 | + | |
| 5 | - | local outputSide = "top" |
| 5 | + | local modem = peripheral.wrap(modemSide) |
| 6 | ||
| 7 | - | while true do |
| 7 | + | |
| 8 | function getReading() | |
| 9 | - | modem.open(1) |
| 9 | + | while true do |
| 10 | - | local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
|
| 10 | + | modem.open(2) |
| 11 | - | modem.closeAll() |
| 11 | + | local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
|
| 12 | - | print("energy reading was: "..message)
|
| 12 | + | modem.closeAll() |
| 13 | - | local energy = message |
| 13 | + | print("mana reading was: "..message)
|
| 14 | - | if energy < limitLow then |
| 14 | + | manaReading = message |
| 15 | - | redstone.setOutput(outputSide,false) |
| 15 | + | |
| 16 | - | hystMem = 0 |
| 16 | + | end |
| 17 | ||
| 18 | - | if (energy >= limitLow) and (energy <= limitHigh) then |
| 18 | + | function oreHarvesting() |
| 19 | - | if hystMem == 0 then redstone.setOutput(outputSide,false) end |
| 19 | + | while true do |
| 20 | - | if hystMem == 1 then redstone.setOutput(outputSide,true) end |
| 20 | + | local success,info = turtle.inspectDown() |
| 21 | if success and (info["name"] ~= "minecraft:stone") and (manaReading > manaLevel) then | |
| 22 | turtle.digDown() | |
| 23 | - | if energy > limitHigh then |
| 23 | + | end |
| 24 | - | redstone.setOutput(outputSide,true) |
| 24 | + | sleep(3) |
| 25 | - | hystMem = 1 |
| 25 | + | end |
| 26 | ||
| 27 | - | end |
| 27 | + | end |
| 28 | ||
| 29 | parallel.waitForAll(getReading,oreHarvesting) |