Advertisement
dannysmc95

Control-Base

Feb 12th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. -- Choose rednet modem side
  2. local side = "back";
  3.  
  4. -- Open Rednet
  5. rednet.open(side)
  6.  
  7. -- Now create the main function
  8. local function main()
  9.     local args = { os.pullEvent() }
  10.     if args[1] == "rednet_message" then
  11.         -- This is the senderid of the computer
  12.         local senderid = args[2]
  13.         -- This is the message
  14.         local message = args[3]
  15.         -- Pass the message to the action function
  16.         action(message)
  17.         -- Log messages
  18.         print("Received: " .. tostring(senderid) .. " > " .. tostring(message))
  19.     end
  20. end
  21.  
  22. -- Now create the control function
  23. local function action(message)
  24.     if (message == "lights") then
  25.         -- Example turn out lights
  26.     elseif (message == "") then
  27.         -- Empty for you
  28.     elseif (message == "") then
  29.         -- Empty for you
  30.     end
  31. end
  32.  
  33. -- Run function
  34. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement