Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- rednet.open("back")
- prot = "engines"
- run = true
- print("ENGINE CONTROLS")
- cTable = {
- ["green"] = colors.green,
- ["red"] = colors.red
- }
- function listen()
- while true do
- sId, msg = rednet.receive(prot)
- tColor = msg:sub(msg:find("|")+1)
- term.setTextColor(cTable[tColor])
- print(msg:sub(1,msg:find("|")-1))
- term.setTextColor(colors.white)
- write("> ")
- end
- end
- function processCommands()
- while true do
- write("> ")
- local isvalid = true
- local cmd = read()
- local rId
- if cmd:find("quarry") ~= nil then
- rId = 10
- elseif cmd:find("chipsets") ~= nil then
- rId = 9
- elseif cmd:find("all") ~= nil then
- rId = -1
- elseif cmd:find("clear") ~= nil then
- term.clear()
- term.setCursorPos(1,1)
- print("ENGINE CONTROLS")
- elseif cmd:find("exit") ~= nil then
- term.clear()
- term.setCursorPos(1,1)
- rednet.close("back")
- run = false
- break
- else
- isvalid = false
- print("Enter a valid command")
- end
- if isvalid and rId ~= nil then
- if rId > 0 then
- rednet.send(rId, cmd, prot)
- elseif rId == -1 then
- rednet.broadcast(cmd, prot)
- end
- end
- end
- end
- while run do
- parallel.waitForAny(listen, processCommands)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement