Advertisement
Guest User

startup

a guest
Jun 16th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.81 KB | None | 0 0
  1. rednet.open("top")
  2. local sg = peripheral.wrap("bottom")
  3. local sg = peripheral.wrap("stargate_2")
  4. local aI = 0
  5. local user_1 = 0
  6. local user_2 = 0
  7.  
  8. mouseWidth = 0
  9. mouseHeight = 0
  10.  
  11. monitor = peripheral.wrap("left")
  12. monitor.clear()
  13. monitor.setCursorPos(1,1)
  14. w, h = monitor.getSize()
  15. -- print("w:", w, "h:", h)
  16.  
  17.  
  18. while true do
  19.     -- Monitor info --
  20.     local St, C = sg.stargateState()
  21.     local lA = sg.localAddress()
  22.     local iS = sg.irisState()
  23.     local rA = sg.remoteAddress()
  24.     monitor.clear()
  25.     monitor.setCursorPos(2, 2)
  26.     monitor.write("The Stargate: " ..St)
  27.     monitor.setCursorPos(2, 4)
  28.     monitor.write("Local Addres " ..sg.localAddress())
  29.     monitor.setCursorPos(2, 6)
  30.     monitor.write("Locked Chevrons: " ..C)
  31.     monitor.setCursorPos(2, 8)
  32.     monitor.write("Iris State: " ..iS)
  33.     monitor.setCursorPos(2, 10)
  34.     monitor.write("Dialling to " ..rA)
  35.    
  36.     -- Connection to --
  37.     if user_1 == 1 then
  38.         monitor.setBackgroundColour((colours.lime))
  39.     else
  40.         monitor.setBackgroundColour((colours.red))
  41.     end
  42.     monitor.setCursorPos(27, 2)
  43.     monitor.write("   Lucas    ")
  44.    
  45.     if user_2 == 1 then
  46.         monitor.setBackgroundColour((colours.lime))
  47.     else
  48.         monitor.setBackgroundColour((colours.red))
  49.     end
  50.     monitor.setCursorPos(27, 4)
  51.     monitor.write("  Pierrick  ")
  52.    
  53.     -- Control iris --
  54.     if iS == "Open" or iS == "Opening" then
  55.         monitor.setBackgroundColour((colours.red))
  56.     else
  57.         monitor.setBackgroundColour((colours.lime))
  58.     end
  59.     monitor.setCursorPos(27, 14)
  60.     monitor.write("  Lock Iris ")
  61.    
  62.     if iS == "Closed" or iS == "Closing" then
  63.         monitor.setBackgroundColour((colours.red))
  64.     else
  65.         monitor.setBackgroundColour((colours.lime))
  66.     end
  67.     monitor.setCursorPos(27, 16)
  68.     monitor.write(" Unlock Iris")
  69.     monitor.setBackgroundColour((colours.orange))
  70.     monitor.setCursorPos(27, 18)
  71.     monitor.write(" Disconnect ")
  72.    
  73.     if aI == 1 then
  74.         monitor.setBackgroundColour((colours.lime))
  75.     else
  76.         monitor.setBackgroundColour((colours.red))
  77.     end
  78.     monitor.setCursorPos(2, 18)
  79.     monitor.write(" Auto Iris  ")
  80.     monitor.setBackgroundColour((colours.black))
  81.  
  82.     -- check button --
  83.     function checkClickPosition()
  84.         if mouseWidth > 26 and mouseWidth < 39 and mouseHeight == 2 then
  85.             address = "Q70C-071-RO"
  86.             ok, result = pcall(sg.dial, address)
  87.             if ok then
  88.                 user_1 = 1
  89.                 print("success")
  90.             else
  91.                 print("error")
  92.             end
  93.         elseif mouseWidth > 26 and mouseWidth < 39 and mouseHeight == 4 then
  94.             address = "Q70C-071-RO"
  95.             ok, result = pcall(sg.dial, address)
  96.             if ok then
  97.                 user_2 = 1
  98.                 print("success")
  99.             else
  100.                 print("error")
  101.             end
  102.         elseif mouseWidth > 26 and mouseWidth < 39 and mouseHeight == 14 then
  103.             aI = 0
  104.             sg.closeIris()
  105.         elseif mouseWidth > 26 and mouseWidth < 39 and mouseHeight == 16 then
  106.             aI = 0
  107.             sg.openIris()
  108.         elseif mouseWidth > 26 and mouseWidth < 39 and mouseHeight == 18 then
  109.             sg.disconnect()
  110.             user_1, user_2 = 0, 0
  111.         elseif mouseWidth > 1 and mouseWidth < 14 and mouseHeight == 18 then
  112.             aI = 1
  113.         end
  114.     end
  115.  
  116.     -- Auto iris --        
  117.     if aI == 1 then
  118.         local id, command, pos = rednet.receive()
  119.         if command == "on" then
  120.             sg.openIris()
  121.         else
  122.             sg.closeIris()
  123.         end
  124.     end    
  125.  
  126.  
  127.     event, p1, p2, p3 = os.pullEvent()
  128.     if event == "monitor_touch" then
  129.         mouseWidth = p2
  130.         mouseHeight = p3
  131.         checkClickPosition()
  132.     end
  133. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement