Guest User

server

a guest
Sep 18th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 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. commands["netherboringmachine"] = 2
  14.  
  15.  
  16. function send (c,s)
  17.     print(c..":"..s)
  18.     if c == 1 then
  19.         -- redstone
  20.         if s == "on" then
  21.             redstone.setOutput("left", false)
  22.         elseif s == "off" then
  23.             redstone.setOutput("left", true)
  24.         end
  25.    
  26.  else
  27.         if rednet.send(24,c.." "..s) then
  28.             print("sent command.")
  29.         else
  30.             print("Sending not successful.")
  31.         end
  32.     end
  33. end
  34.  
  35. function init ()
  36.     if rednet.isOpen(WLAN) == false then
  37.         rednet.open(WLAN)
  38.     end
  39. end
  40.  
  41. init()
  42. local answer,command, status
  43. repeat
  44.     io.flush()
  45.     _,_,answer= os.pullEvent("rednet_message")
  46.  
  47.     -- check answer
  48.     answer = string.lower(answer)
  49.     command, status = string.find(answer," ") -- found positions
  50.     if command ~= nil then
  51.         command = string.sub(answer, 1, command-1) -- found command
  52.         status = string.sub(answer, status+1) -- found status
  53.         if status ~= nil and commands[command] ~= nil then
  54.             send(commands[command],status)
  55.         end
  56.     end
  57. until false
Advertisement
Add Comment
Please, Sign In to add comment