Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Booting...")
- local IDList = "372,373, 374-379, 432, 433, 434" --list IDs of your turtles here
- local startMsg = "start13" --the number are seconds for sleep()
- print("Hotkeys: \n")
- print("\"S\" - Start the quarry")
- print("\"E\" - Stop the quarry")
- print("Run program \"moveQuarry\" to move the quarry")
- if not modemSide then modemSide = "top" end
- if not rednet.isOpen(modemSide) then rednet.open(modemSide) end
- local work = true
- local button = false
- --[[ Count IDs ]]
- local IDList = string.gsub(IDList, " ", "")
- local IDTable, i = {}, 1
- for word in string.gmatch(IDList, "[^,]%d+") do --part of: Code not published yet
- IDTable[i]=tonumber(word)
- if IDTable[i]>0 then
- i=i+1 --proceed
- else --it's an array of IDs 204-207
- local prev, curr = IDTable[i-1], IDTable[i]*-1 --faster than math.abs()
- local step = 1
- if prev > curr then --if the first number is bigger than the second one (e.g. "470-464")
- step = -1 --we need to count downwards
- end
- i = i-1 --trust me. We don't wanna to have the same ID twice
- for x = prev, curr, step do
- IDTable[i] = x
- i = i+1
- end
- end
- end
- --[[ End Of ]]
- function sendStart()
- for _,i in pairs(IDTable) do
- rednet.send(i, startMsg)
- end
- print("Sent start commands!")
- end
- function sendStop()
- for _,i in pairs(IDTable) do
- rednet.send(i, "shutdown")
- end
- end
- parallel.waitForAny(
- function ()
- while true do
- local fromID, msg = rednet.receive()
- if msg == "done" then --when ready with current row
- --Move the quarry
- sleep(0.25)
- redstone.setOutput("right", true); sleep(0.75) --contents of moveQuarry programm
- redstone.setOutput("right", false);
- redstone.setOutput("back", true); sleep(1)
- redstone.setOutput("back", false); --end of moveQuarry programm
- --Launch the turtles
- for _,i in pairs(IDTable) do
- rednet.send(i, "go")
- end
- else
- print("Wrong message: "..msg)
- end
- end
- end,
- function ()
- while true do
- if work==false then return true end
- local event, key = os.pullEvent("key")
- if key==31 then -- "s"
- if not button then
- sendStart()
- button = true
- end
- elseif key==18 then -- "e"
- print("Turning off the turtles...")
- sendStop()
- rednet.close("top")
- work = false
- button = false
- --elseif key==34 then -- "g"
- print("\nQuarry Server stopped!")
- end
- end
- end
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement