Advertisement
Guest User

UtilNode

a guest
Jan 26th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1. -- Config
  2. os.loadAPI("LightCtrl")
  3. --os.loadAPI("DoorCtrl")
  4. rs.setOutput("left", true)
  5.  
  6.  
  7. -- Globals
  8. me = string.format("%04d", os.getComputerID())
  9. comm = {}
  10.  
  11. function decodeBCast(message)
  12.   local i = 0
  13.  
  14.   if type(message) == "string" then
  15.     for w in string.gmatch(message, "%w+") do
  16.       comm[i] = w
  17.       i = i+1
  18.     end
  19.     if comm[1] == me then
  20.       return true
  21.     end
  22.   end  
  23.   return false
  24. end
  25.  
  26. while true do
  27.   local senderId, message, protocol = rednet.receive()
  28.   if protocol == "LightControl" and LightCtrl.enabled == true then
  29.     if decodeBCast(message) == true then
  30.       LightCtrl.process(comm)
  31.     end
  32.   end  
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement