Erlendftw

CC/Lightsystem

Jun 27th, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.56 KB | None | 0 0
  1. --left: emergency kill switch
  2. --back: light sensor
  3. --right: output for lights
  4.  
  5. function setLights(status)
  6.     if (status ~= "on" and status ~= "off") then
  7.         print("invalid status")
  8.         return
  9.     end
  10.  
  11.     if (status == "on") then
  12.         rs.setOutput("right", true)
  13.     elseif (status == "off") then
  14.         rs.setOutput("right", false)
  15.     end
  16. end
  17.  
  18. kill = false
  19. while (kill ~= true) do
  20.     if (rs.getInput("left") == true) then kill = true end
  21.  
  22.     if (rs.getInput("back") == true) then
  23.         setLights("off")
  24.     elseif (rs.getInput("back") == false) then
  25.         setLights("on")
  26.     end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment