warfar

Redstone ON/OFF Controller

Jan 20th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. --Program made by Warfar
  2. --http://pastebin.com/u/warfar
  3.  
  4.  
  5. term.clear()
  6. term.setCursorPos(1 , 1)
  7. local status
  8.  
  9. if redstone.getInput("back") == true then
  10.     status = "ON"
  11. else status = "OFF"
  12. end
  13. local i = 0
  14.  
  15. local function printstatus()
  16.     term.clear()
  17.     term.setCursorPos(1 , 1)
  18.     print("==========")
  19.     print("  STATUS  ")
  20.     print("    ON    ")
  21.     print("==========")
  22.     print("   >ON<   ")
  23.     print("    OFF   ")
  24.     print("==========")
  25.     term.setCursorPos(5 , 4)
  26. end
  27.  
  28. local function printstatusoff()
  29.     term.clear()
  30.     term.setCursorPos(1 , 1)
  31.     print("==========")
  32.     print("  STATUS  ")
  33.     print("    OFF   ")
  34.     print("==========")
  35.     print("    ON    ")
  36.     print("   >OFF<  ")
  37.     print("==========")
  38.     term.setCursorPos(5 , 4)
  39. end
  40.  
  41. printstatus()
  42.  
  43. while true do
  44.     local key = os.pullEvent("key")
  45.     if key == 208 and i == 0 then
  46.         printstatusoff()
  47.         i = 1
  48.     end
  49.     if key == 28 and i == 0 then
  50.         status = "ON"
  51.     elseif param1 == 28 and i == 1 then
  52.         status = "OFF"
  53.         printstatus()
  54.     end
  55.     if key == 200 and i == 1 then
  56.         printstatus()
  57.         i = 0
  58.     end
  59.     if status == "ON" then
  60.         redstone.setOutput("back", true)
  61.     end
  62.     if status == "OFF" then
  63.         redstone.setOutput("back", false)
  64.     end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment