Advertisement
Guest User

Untitled

a guest
Sep 1st, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. --[[
  2.  
  3. Control_Interface:14
  4. Control_RedstoneServer:15
  5. Control_RedstoneClient1:24
  6. Control_Bee:25
  7.  
  8. --]]
  9.  
  10. local WLAN = "bottom"
  11. local commands = {} --
  12. commands["boringmachine"] = 1 -- not nil!
  13.  
  14.  
  15. function send (c,s)
  16.     print(c..":"..s)
  17.     if c == 1 then
  18.         -- redstone
  19.         if s == "on" then
  20.             redstone.setOutput("left", false)
  21.         elseif s == "off" then
  22.             redstone.setOutput("left", true)
  23.         end
  24.     else
  25.         if rednet.send(24,c.." "..s) then
  26.             print("sent command.")
  27.         else
  28.             print("Sending not successful.")
  29.         end
  30.     end
  31. end
  32.  
  33. function init ()
  34.     if rednet.isOpen(WLAN) == false then
  35.         rednet.open(WLAN)
  36.     end
  37. end
  38.  
  39. init()
  40. local answer,command, status
  41. repeat
  42.     io.flush()
  43.     _,_,answer= os.pullEvent("rednet_message")
  44.  
  45.     -- check answer
  46.     answer = string.lower(answer)
  47.     command, status = string.find(answer," ") -- found positions
  48.     if command ~= nil then
  49.         command = string.sub(answer, 1, command-1) -- found command
  50.         status = string.sub(answer, status+1) -- found status
  51.         if status ~= nil and commands[command] ~= nil then
  52.             send(commands[command],status)
  53.         end
  54.     end
  55. until false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement