Advertisement
Guest User

startup

a guest
Jun 25th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.78 KB | None | 0 0
  1. mon = peripheral.wrap("top")
  2.  
  3. mouseWidth = 0
  4. mouseHeight = 0
  5.    
  6.  
  7. mon.setTextScale(0.5)
  8.  
  9. button = {}
  10.  
  11. button["x"] = {3,3,3,3}
  12. button["length"] = {53,53,53,53}  
  13. button["y"] = {3,7,11,15}
  14. button["height"] = {3,3,3,3}    
  15.  
  16. button["txt"] = {"Hallway Lights","zombie","skeleton","bill"}
  17.    
  18. button["state"] = {0,0,0,0}
  19. button["colour"] = {colors.white, colors.orange, colors.orange,colors.blue}  
  20. button["side"] = {"left","left","right","left"}
  21.      
  22. function clear()
  23.     mon.setBackgroundColor(colors.black)
  24.         mon.clear()
  25. end
  26.  
  27.     clear()
  28.  
  29. function setTable()
  30.  
  31.     for i = 1,#button["x"] do
  32.        
  33.         if button["state"][i] == 1 then
  34.             mon.setBackgroundColor(colors.white)
  35.         else
  36.             mon.setBackgroundColor(colors.gray)
  37.         end
  38.        
  39.             for y = 0, button["height"][i] - 1 do
  40.                 mon.setCursorPos(button["x"][i], button["y"][i] + y)
  41.                     mon.write(string.rep(" ",button["length"][i]))
  42.             end
  43.    
  44.    buttonX = button["x"][i] + ((button["length"][i] - string.len(button["txt"][i])) / 2)
  45.    
  46.     print(buttonX)
  47.    
  48.     mon.setCursorPos(buttonX, button["y"][i] + 1)
  49.        mon.setTextColor(colors.black)
  50.         mon.write(button["txt"][i])
  51.    
  52.     end
  53. end        
  54.        
  55.     setTable()    
  56.  
  57.    
  58. function Redstone()
  59.     rs.setBundledOutput("back",0)
  60.         for i = 1,#button["state"] do
  61.  
  62.             if button["state"][i] == 1 then
  63.                 rs.setBundledOutput(button["side"][i],colors.combine(rs.getBundledOutput(button["side"][i]),button["colour"][i]))
  64.                     else
  65.                 rs.setBundledOutput(button["side"][i],colors.subtract(rs.getBundledOutput(button["side"][i]),button["colour"][i]))
  66.             end
  67.         end
  68. end        
  69.              
  70.    Redstone()              
  71.                        
  72.                                  
  73.                
  74.                      
  75. function BP()
  76.  
  77.     for i = 1,#button["x"] do
  78.         if mouseWidth > button["x"][i] - 1 and mouseWidth < (button["length"][i] + button["x"][i]) and mouseHeight > button["y"][i] - 1 and mouseHeight < (button["height"][i] + button["y"][i] + 1) then
  79.             button["state"][i] = button["state"][i] + 1
  80.                 if button["state"][i] >= 2 then
  81.                     button["state"][i] = 0
  82.                 end
  83.         end
  84.             setTable()
  85.         Redstone()
  86.     end                            
  87. end
  88.  
  89.            
  90.                        
  91. function Press()
  92.    
  93.     repeat
  94.        
  95.         event,p1,p2,p3 = os.pullEvent()
  96.        
  97.             if event=="monitor_touch" then
  98.            
  99.             mouseWidth = p2
  100.             mouseHeight = p3
  101.             BP()
  102.            
  103.             end
  104.     until event=="char" and p1==("x")
  105. end
  106.  
  107. Press()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement