Advertisement
Guest User

swarmOS.lua

a guest
Oct 25th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. local m=component.proxy(component.list("modem")())
  2. local g=component.proxy(component.list("geolyzer")())
  3.  
  4. local id = "001"
  5. local pCMD
  6. local pRTS
  7.  
  8. m.open(1231)
  9.  
  10.  
  11. function handling(x)
  12.   if string.match(load(x),"^function") == "function" then
  13.     return(true)
  14.   else
  15.     m.broadcast("DNT "..load(x))
  16.     return(false)
  17.   end
  18. end
  19.  
  20.  
  21. function logistics(y)
  22.   if string.match(y,"^"..id)==id then
  23.     return(true)
  24.   else
  25.     if y ~= pCMD then
  26.       m.boradcast(y)
  27.       pCMD = y
  28.     end
  29.     return(false)
  30.   end
  31. end
  32.  
  33. function execute(z)
  34.   local purpose = string.sub(z,5)
  35.   purpose()
  36.   m.broadcast("RTS: roger wilco")
  37. end
  38.  
  39. while true do
  40.   local _,_,_,_,_,cmd = computer.pullSignal()
  41.  
  42.   if string.match(cmd,"^RTS")=="RTS" then
  43.     if cmd ~= pRTS then
  44.       m.broadcast(cmd)
  45.       pRTS = cmd
  46.     end
  47.   else
  48.     if string.match(cmd,"^DNT")~="DNT" then
  49.       if handling(cmd) == true then
  50.         if logistics(cmd) == true then
  51.           execute(cmd)
  52.         end
  53.       end
  54.     end
  55.   end
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement