Advertisement
rhn

Alveary temperature control

rhn
Jun 23rd, 2014
631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.11 KB | None | 0 0
  1. -- 1 wide, 2 tall Advanced monitor on top of Advanced Computer. Bundled cable or MFR rednet cable out of bottom of Computer.
  2. -- Based on placing in a Normal temp biome.
  3. -- Colour channels:
  4. -- White: Power switch(Energy cells or similar) to heaters required to reach "Warm" level(4 heaters in my case).
  5. -- Orange: Power switch for heaters which in addition to White is required to reach "Hot" level (4 heaters in my case, 8 heaters total)
  6. -- Magenta: Power switch for Alveary Fans required to reach "Cold" level(2 fans in my case).
  7.  
  8. mouseWidth = 0
  9. mouseHeight = 0
  10.  
  11. monitor = peripheral.wrap("top")
  12.  
  13. monitor.clear()
  14.  
  15.  
  16. monitor.setCursorPos(1,1)
  17.  
  18. w,h=monitor.getSize()
  19.  
  20. print(w)
  21. print(h)
  22.  
  23. -- Draw buttons
  24. monitor.setCursorPos(1,2)
  25. monitor.write("Alveary")
  26. monitor.setCursorPos(1,3)
  27. monitor.write(" Temp.")
  28.  
  29. monitor.setBackgroundColour((colours.green))
  30. monitor.setCursorPos(1,5)
  31. monitor.write("  HOT  ")
  32.  
  33. monitor.setBackgroundColour((colours.green))
  34. monitor.setCursorPos(1,7)
  35. monitor.write(" WARM  ")
  36.  
  37. monitor.setBackgroundColour((colours.lime))
  38. monitor.setCursorPos(1,9)
  39. monitor.write("NORMAL ")
  40.  
  41. monitor.setBackgroundColour((colours.green))
  42. monitor.setCursorPos(1,11)
  43. monitor.write(" COLD  ")
  44.  
  45. monitor.setBackgroundColour((colours.black))
  46.  
  47.  
  48.  
  49. -- Check click function
  50.  
  51. function checkClickPosition()
  52.   if mouseWidth > 1 and mouseWidth < 7 and mouseHeight == 5 then
  53.     -- button HOT clicked
  54.     monitor.setBackgroundColour((colours.lime))
  55.     monitor.setCursorPos(1,5)
  56.     monitor.write("  HOT  ")
  57.  
  58.     monitor.setBackgroundColour((colours.green))
  59.     monitor.setCursorPos(1,7)
  60.     monitor.write(" WARM  ")
  61.  
  62.     monitor.setBackgroundColour((colours.green))
  63.     monitor.setCursorPos(1,9)
  64.     monitor.write("NORMAL ")
  65.  
  66.     monitor.setBackgroundColour((colours.green))
  67.     monitor.setCursorPos(1,11)
  68.     monitor.write(" COLD  ")
  69.  
  70.     monitor.setBackgroundColour((colours.black))
  71.  
  72.         redstone.setBundledOutput("bottom", colours.white+colours.orange)
  73.     sleep(1)
  74.   elseif mouseWidth > 1 and mouseWidth < 7 and mouseHeight == 7 then
  75.     -- button WARM clicked
  76.     monitor.setBackgroundColour((colours.green))
  77.     monitor.setCursorPos(1,5)
  78.     monitor.write("  HOT  ")
  79.  
  80.     monitor.setBackgroundColour((colours.lime))
  81.     monitor.setCursorPos(1,7)
  82.     monitor.write(" WARM  ")
  83.  
  84.     monitor.setBackgroundColour((colours.green))
  85.     monitor.setCursorPos(1,9)
  86.     monitor.write("NORMAL ")
  87.  
  88.     monitor.setBackgroundColour((colours.green))
  89.     monitor.setCursorPos(1,11)
  90.     monitor.write(" COLD  ")
  91.  
  92.     monitor.setBackgroundColour((colours.black))
  93.  
  94.         redstone.setBundledOutput("bottom",colours.white)
  95.     sleep(1)
  96.   elseif mouseWidth > 1 and mouseWidth < 7 and mouseHeight == 9 then
  97.     -- button NORMAL clicked
  98.     monitor.setBackgroundColour((colours.green))
  99.     monitor.setCursorPos(1,5)
  100.     monitor.write("  HOT  ")
  101.  
  102.     monitor.setBackgroundColour((colours.green))
  103.     monitor.setCursorPos(1,7)
  104.     monitor.write(" WARM  ")
  105.  
  106.     monitor.setBackgroundColour((colours.lime))
  107.     monitor.setCursorPos(1,9)
  108.     monitor.write("NORMAL ")
  109.  
  110.     monitor.setBackgroundColour((colours.green))
  111.     monitor.setCursorPos(1,11)
  112.     monitor.write(" COLD  ")
  113.  
  114.     monitor.setBackgroundColour((colours.black))
  115.  
  116.         redstone.setBundledOutput("bottom",0)
  117.     sleep(1)
  118.   elseif mouseWidth > 1 and mouseWidth < 7 and mouseHeight == 11 then
  119.     -- button NORMAL clicked
  120.     monitor.setBackgroundColour((colours.green))
  121.     monitor.setCursorPos(1,5)
  122.     monitor.write("  HOT  ")
  123.  
  124.     monitor.setBackgroundColour((colours.green))
  125.     monitor.setCursorPos(1,7)
  126.     monitor.write(" WARM  ")
  127.  
  128.     monitor.setBackgroundColour((colours.green))
  129.     monitor.setCursorPos(1,9)
  130.     monitor.write("NORMAL ")
  131.  
  132.     monitor.setBackgroundColour((colours.lime))
  133.     monitor.setCursorPos(1,11)
  134.     monitor.write(" COLD  ")
  135.  
  136.     monitor.setBackgroundColour((colours.black))
  137.  
  138.         redstone.setBundledOutput("bottom",colours.magenta)
  139.     sleep(1)
  140.   end
  141. end
  142.  
  143. redstone.setBundledOutput("bottom",0)
  144.  
  145.  
  146.  
  147. repeat
  148.     event,p1,p2,p3 = os.pullEvent()
  149.         if event=="monitor_touch" then
  150.                 mouseWidth = p2 -- sets mouseWidth
  151.                 mouseHeight = p3 -- and mouseHeight
  152.                 checkClickPosition() -- this runs our function
  153.         end
  154. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement