Advertisement
Guest User

Smart-House Software

a guest
Dec 28th, 2011
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.36 KB | None | 0 0
  1. print("---------------------------------")
  2. print("Welcome to Smart-House Software")
  3. print("Please Select a Task")
  4. print("---------------------------------")
  5.     alarmout = "left"
  6.     alarmstat = "on"
  7.     alarmfinish = "0"
  8.     lightout = "back"
  9.     lightstat = "on"
  10.     loop = 0
  11. print("1.Turn " ..lightstat.. " Lights")
  12. print("2.Turn " ..alarmstat.. " Alarm")
  13. print("3.Change outputs")
  14. print("---------------------------------")
  15.  
  16. while loop == 0 do
  17.    
  18.     function Printit()
  19.         print("---------------------------------")
  20.         print("Welcome to Smart-House Software")
  21.         print("Please Select a Task")
  22.         print("---------------------------------")
  23.         print("1.Turn " ..lightstat.. " Lights")
  24.         print("2.Turn " ..alarmstat.. " Alarm")
  25.         print("3.Change outputs")
  26.         print("---------------------------------")
  27.         task = read()
  28.     end
  29. task = read()
  30.  
  31.     if task == "debug" then
  32.         print("---------------------------------")
  33.         print("Debugging Activated")
  34.         print("Type stop to finish Debugging")
  35.         print("---------------------------------")
  36.         break
  37.     end
  38.     if task == "1" or task == "lights" then
  39.         if lightstat == "off" then
  40.         loop = 1
  41.             redstone.setOutput(lightout, true)
  42.            
  43.             print("---------------------------------")
  44.             print("Lights have been turned on")
  45.             print("---------------------------------")
  46.            
  47.             sleep (5)
  48.             term.clear()
  49.             term.setCursorPos(1,1)
  50.             Printit()
  51.             lightstat = "on"
  52.             loop = 0
  53.         end
  54.             if lightstat == "on" then
  55.             loop = 1
  56.             redstone.setOutput(lightout, false)
  57.          
  58.             print("---------------------------------")
  59.             print("Lights have been turned off")
  60.             print("---------------------------------")
  61.            
  62.             sleep (5)
  63.             term.clear()
  64.             term.setCursorPos(1,1)
  65.             print("---------------------------------")
  66.             print("Welcome to Smart-House Software")
  67.             print("Please Select a Task")
  68.             print("---------------------------------")
  69.             print("1.Turn " ..lightstat.. " Lights")
  70.             print("2.Turn " ..alarmstat.. " Alarm")
  71.             print("3.Change outputs")
  72.             print("---------------------------------")
  73.              lightstat = "off"
  74.              loop = 0
  75.         end
  76.     end
  77.    
  78.     if task == "2" or task == "alarm" then
  79.    
  80.         if alarmstat == "on" then
  81.             alarmstat = "off"
  82.             alarmfinish = "0"
  83.            
  84.             print("---------------------------------")
  85.             print("Alarm has been turned on")
  86.             print("---------------------------------")
  87.                 loop = 1
  88.             sleep (5)
  89.             term.clear()
  90.             term.setCursorPos(1,1)
  91.             Printit()
  92.             loop = 0
  93.             while alarmfinish == "0" do
  94.                     sleep(1)
  95.                     redstone.setOutput(alarmout, true)
  96.                     sleep(0.5)
  97.                     redstone.setOutput(alarmout, false)
  98.                    alarmfinish = "1"
  99.                    alarmstat = "off"
  100.                 end
  101.         end
  102.         if alarmstat == "off" then
  103.             alarmstat = "on"
  104.             print("---------------------------------")
  105.             print("Alarm has been turned off")
  106.             print("---------------------------------")
  107.             alarmfinish = "1"
  108.             loop = 1
  109.             sleep (5)
  110.             term.clear()
  111.             term.setCursorPos(1,1)
  112.             Printit()
  113.             loop = 0
  114.         end
  115.     end
  116.     if task == "3" or task == "change" then
  117.     loop = 1
  118.     term.clear()
  119.             term.setCursorPos(1,1)
  120.         print("---------------------------------")
  121.         print("What Output would you like to change?")
  122.         print("---------------------------------")
  123.         print("Lights")
  124.         print("Alarm")
  125.         print("---------------------------------")
  126.         output = read()
  127.         loop = 0
  128.         if output == "Lights" or output == "lights" then
  129.             term.clear()
  130.             term.setCursorPos(1,1)
  131.             loop = 1
  132.             print("---------------------------------")
  133.             print("Light Output")
  134.             print("---------------------------------")
  135.             print("Please type the direction in which you want to output power")
  136.             print("---------------------------------")
  137.             print("List of Directions")
  138.             print("---------------------------------")
  139.             print("Front")
  140.             print("Back")
  141.             print("Left")
  142.             print("Right")
  143.             print("---------------------------------")
  144.             loop = 0
  145.             direction = read()
  146.                 if direction == "Front" or direction == "front" then
  147.                     if lightout == alarmout then
  148.                         print("---------------------------------")
  149.                         print("Please Choose another Direction")
  150.                         print("---------------------------------")
  151.                         else
  152.                         lightout = "front"
  153.                         loop = 1
  154.                         print("---------------------------------")
  155.                         print("Light Output set to " ..lightout.. " side")
  156.                         print("---------------------------------")
  157.                         sleep(3)
  158.                         term.clear()
  159.                         term.setCursorPos(1,1)
  160.                         Printit()
  161.                         loop = 0
  162.                     end
  163.                 elseif direction == "Back" or direction == "back" then
  164.                     if lightout == alarmout then
  165.                         print("---------------------------------")
  166.                         print("Please Choose another Direction")
  167.                         print("---------------------------------")
  168.                         else
  169.                         lightout = "back"
  170.                         loop = 1
  171.                         print("---------------------------------")
  172.                         print("Light Output set to " ..lightout.. " side")
  173.                         print("---------------------------------")
  174.                         sleep(3)
  175.                         term.clear()
  176.                         term.setCursorPos(1,1)
  177.                         Printit()
  178.                         loop = 0
  179.                     end
  180.                 elseif direction == "Left" or direction == "left" then
  181.                     if lightout == alarmout then
  182.                         print("---------------------------------")
  183.                         print("Please Choose another Direction")
  184.                         print("---------------------------------")
  185.                         else
  186.                         lightout = "left"
  187.                         loop = 1
  188.                         print("---------------------------------")
  189.                         print("Light Output set to " ..lightout.. " side")
  190.                         print("---------------------------------")
  191.                         sleep(3)
  192.                         term.clear()
  193.                         term.setCursorPos(1,1)
  194.                         Printit()
  195.                         loop = 0
  196.                     end
  197.                 elseif direction == "Right" or direction == "right" then
  198.                     if lightout == alarmout then
  199.                         print("---------------------------------")
  200.                         print("Please Choose another Direction")
  201.                         print("---------------------------------")
  202.                         else
  203.                         lightout = "right"
  204.                         loop = 1
  205.                         print("---------------------------------")
  206.                         print("Light Output set to " ..lightout.. " side")
  207.                         print("---------------------------------")
  208.                         sleep(3)
  209.                         term.clear()
  210.                         term.setCursorPos(1,1)
  211.                         Printit()
  212.                         loop = 0
  213.                     end    
  214.                 end
  215.         end
  216.         if output == "alarm" or output == "Alarm" then
  217.             term.clear()
  218.             term.setCursorPos(1,1)
  219.             loop = 1
  220.             print("---------------------------------")
  221.             print("Alarm Output")
  222.             print("---------------------------------")
  223.             print("Please type the direction in which you want to output power")
  224.             print("---------------------------------")
  225.             print("List of Directions")
  226.             print("---------------------------------")
  227.             print("Front")
  228.             print("Back")
  229.             print("Left")
  230.             print("Right")
  231.             print("---------------------------------")
  232.             loop = 0
  233.             adirection = read()
  234.             if adirection == "Front" or adirection == "front" then
  235.                     if lightout == alarmout then
  236.                         print("---------------------------------")
  237.                         print("Please Choose another Direction")
  238.                         print("---------------------------------")
  239.                         else
  240.                         alarmout = "front"
  241.                         loop = 1
  242.                         print("---------------------------------")
  243.                           print("Alarm Output set to " ..alarmout.. " side")
  244.                         print("---------------------------------")
  245.                         sleep(3)
  246.                         term.clear()
  247.                         term.setCursorPos(1,1)
  248.                         Printit()
  249.                         loop = 0
  250.                     end
  251.                 elseif adirection == "Back" or adirection == "back" then
  252.                     if lightout == alarmout then
  253.                         print("---------------------------------")
  254.                         print("Please Choose another Direction")
  255.                         print("---------------------------------")
  256.                         else
  257.                         alarmout = "back"
  258.                         loop = 1
  259.                         print("---------------------------------")
  260.                           print("Alarm Output set to " ..alarmout.. " side")
  261.                         print("---------------------------------")
  262.                         sleep(3)
  263.                         term.clear()
  264.                         term.setCursorPos(1,1)
  265.                         Printit()
  266.                         loop = 0
  267.                     end
  268.                 elseif adirection == "Left" or adirection == "left" then
  269.                     if lightout == alarmout then
  270.                         print("---------------------------------")
  271.                         print("Please Choose another Direction")
  272.                         print("---------------------------------")
  273.                         else
  274.                         alarmout = "left"
  275.                         loop = 1
  276.                         print("---------------------------------")
  277.                           print("Alarm Output set to " ..alarmout.. " side")
  278.                         print("---------------------------------")
  279.                         sleep(3)
  280.                         term.clear()
  281.                         term.setCursorPos(1,1)
  282.                         Printit()
  283.                         loop = 0
  284.                     end
  285.                 elseif adirection == "Right" or adirection == "right" then
  286.                     if lightout == alarmout then
  287.                         print("---------------------------------")
  288.                         print("Please Choose another Direction")
  289.                         print("---------------------------------")
  290.                         else
  291.                         alarmout = "right"
  292.                         loop = 1
  293.                         print("---------------------------------")
  294.                         print("Alarm Output set to " ..alarmout.. " side")
  295.                         print("---------------------------------")
  296.                         sleep(3)
  297.                         term.clear()
  298.                         term.setCursorPos(1,1)
  299.                         Printit()
  300.                         loop = 0
  301.                     end    
  302.                 end
  303.     end      
  304.  end      
  305. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement