Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Starting...")
- if not modemSide then modemSide = "right" end
- local serverID = 358
- local sleepTime = 10 --default sleep time if not defined by the server
- -- mining well slot = 1
- local startMsg = "start"
- local endMsg = "shutdown"
- if not rednet.isOpen(modemSide) then rednet.open(modemSide) end
- turtle.select(1)
- function mine()
- turtle.place() --place mining well
- turtle.up()
- --sleep(0.15) -- a safe solution from picking up mining well's items
- --redstone.setOutput("back", true)
- sleep(sleepTime) -- subtract 0.15 from here
- print("sleepTime: "..sleepTime)
- --redstone.setOutput("back", false)
- turtle.down()
- turtle.dig()
- --rednet.send(serverID, "done")
- end
- while true do
- local fromID, msg = rednet.receive()
- if string.sub(msg, 1, 2)=="go" then --continue mining
- mine()
- elseif msg == endMsg then --onStop
- print("Stopping the mining!")
- elseif string.find(msg, startMsg) then --onStart
- print("Beginning to work...")
- local s, e = string.find(msg, "%d+")
- print(s,e)
- if s then --custom sleepTimer
- print("true!!!")
- local sTime = tonumber(string.sub(msg, s, e))
- if sTime~=sleepTime then
- sleepTime = sTime
- print("sleepTime set to \""..sleepTime.."\"")
- else
- print("not equal!")
- end
- end
- mine()
- else
- print("Wrong message: "..msg)
- end
- end
- print("Shutting down...")
- print("Power off.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement