Advertisement
Techtronic

SpawnerControlV1

Apr 3rd, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. --[[so how do i get comControl to catch fansOn and lightsOff and put them into
  2.  fanStat and lightStat]]
  3.  
  4.  rednet.open("back")
  5.  
  6. local fanStat
  7. local lightStat
  8. local getFanStat = false
  9. local getLightStat = false
  10. local who
  11.  
  12. local event, param1, param2, param3
  13.  
  14. local Keys = {
  15. [16] = function() --Q
  16.     getFanStat = true
  17.     rednet.broadcast("fansCheck")
  18. end,
  19. [17] = function() --W
  20.     rednet.broadcast("fansOn")
  21.     fanStat = true
  22. end,
  23. [18] = function() --E
  24.     rednet.broadcast("fansOff")
  25.     fanStat = true
  26. end,
  27. [30] = function() --A
  28.     getLightStat = true
  29.     rednet.broadcast("lightsCheck")
  30. end,
  31. [31] = function() --S
  32.     rednet.broadcast("lightsOn")
  33.     lightStat = true
  34. end,
  35. [32] = function() --D
  36.     rednet.broadcast("lightsOff")
  37.     lightStat = false
  38. end
  39.  }
  40.  
  41. term.setCursorPos(1,1)
  42. term.clear()
  43.  
  44. Keys[16]()
  45. Keys[30]()
  46.  
  47. while true do
  48.     event, param1, param2, param3 = os.pullEvent()
  49.    
  50.     if event == "rednet_message" then
  51.         local senderID, message = param1, param2
  52.  
  53.         if getFanStat == true then
  54.             fanStat = message
  55.             if senderID == 4 then
  56.                 who = "lights"
  57.                 term.setCursorPos(1,1)
  58.                 term.clearLine()
  59.             elseif senderID == 5 then
  60.                 who = "fans"
  61.                 term.setCursorPos(1,2)
  62.                 term.clearLine()
  63.             end
  64.             print(who .. " : " .. tostring(message))
  65.         elseif getLightStat == true then
  66.             lightStat = message
  67.             term.clear()
  68.             term.setCursorPos(1,1)
  69.             if senderID == 4 then
  70.                 who = "lights"
  71.                 term.setCursorPos(1,1)
  72.                 term.clearLine()
  73.             elseif senderID == 5 then
  74.                 who = "fans"
  75.                 term.setCursorPos(1,2)
  76.                 term.clearLine()
  77.             end
  78.             print(who .. " : " .. tostring(message))
  79.         end
  80.        
  81.     elseif event == "key" then
  82.         local key = param1
  83.         if Keys[key] ~= nil then
  84.             Keys[key]()
  85.         end
  86.     end
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement