Guest User

engines

a guest
Aug 21st, 2019
134
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. args = {...}
  2. if #args > 0 then
  3.   name = table.concat(args, " ")
  4. else
  5.   error("Provide a name")
  6. end  
  7.  
  8. shell.run("clear")
  9. local rside = "front"
  10. rednet.open("top")
  11.  
  12. while true do
  13.   print(os.getComputerID(),": ",name," - Waiting for input...")
  14.   sId, msg, prot = rednet.receive("engines")
  15.   local replymsg
  16.   local trim = msg:find(" ")
  17.   if trim ~= nil then
  18.     isvalid = true
  19.     cmd = msg:sub(trim):gsub("%s+","")
  20.    
  21.     if cmd == "on" then
  22.       rs.setOutput(rside, true)
  23.     elseif cmd == "off" then
  24.       rs.setOutput(rside, false)
  25.     elseif cmd == "status" then
  26.       -- do nothing
  27.     elseif cmd == "ids" then
  28.       replymsg = os.getComputerID()..": "..name
  29.     else
  30.       isvalid = false
  31.     end
  32.    
  33.     if isvalid and replymsg == nil then
  34.       replymsg = name.." - Engines Running: "..tostring(rs.getOutput(rside)).."|green"
  35.     elseif replymsg ~= nil then
  36.       -- do nothing
  37.     else
  38.       replymsg = name.." - Invalid Command|red"
  39.     end
  40.   else
  41.     replymsg = unit.." - Invalid Command|red"
  42.   end
  43.  
  44.   rednet.send(sId, replymsg, prot)
  45.   print(replymsg:sub(1,replymsg:find("|")-1))
  46. end
  47.  
  48. rednet.close("top")
RAW Paste Data