Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local m = peripheral.find("modem")
- local senderID = os.getComputerLabel() == nil and "ID:" .. os.getComputerID() or os.getComputerLabel()
- local channels = {
- ["stdout"] = 1000,
- ["stdin"] = 1001,
- ["witherout"] = 1010,
- ["witherin"] = 1011
- }
- m.open(channels.stdin)
- local args = {...}
- local digFunc = turtle.dig
- if args[1] == "up" then
- digFunc = turtle.digUp
- elseif args[1] == "down" then
- digFunc = turtle.digDown
- end
- local xTime = os.clock()
- local function checkStop()
- if os.clock() >= xTime then
- os.startTimer(0.15)
- local a, b, c, d, e
- repeat
- evt, face, sendCh, replyCh, msg, dist = os.pullEvent()
- if evt == "modem_message" and msg.type == "cmd" and msg.cmd == "sigterm" and (msg.receiver == nil or (type(msg.receiver) == "string" and string.match(senderID, msg.receiver))) then
- return true
- end
- until evt == "timer"
- xTime = os.clock() + 2.5
- end
- return false
- end
- while true do
- if checkStop() then
- break
- end
- digFunc()
- end
Add Comment
Please, Sign In to add comment