Homerdu29Off

Stargate DHD Bsa

Aug 26th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.68 KB | None | 0 0
  1. monside = peripheral.wrap("monitor_0")
  2. monup   = peripheral.wrap("monitor_2")
  3. sg      = peripheral.wrap("stargate_0")
  4.  
  5. boolIris = false
  6. mainMenu = true
  7. menuPrivate = false
  8. gate = "stargate_0"
  9. energyMax = 1000000
  10.  
  11. -- STARTUP --
  12. if irisState == "Open" then
  13.     boolIris = false
  14. else
  15.     boolIris = true
  16. end
  17. -------------
  18.  
  19. function TouchScreen()
  20.     -- TOUCH SCREEN --
  21.     local event, side, arg1, arg2 = os.pullEvent()
  22.    
  23.     if event == "monitor_touch" then
  24.         if side == "monitor_2" then
  25.         -- bouton iris --
  26.             if (arg1 > 1 and arg1 < 13) and
  27.                (arg2 > 10 and arg2 < 12) and
  28.                (irisState == "Closed" or
  29.                 irisState == "Open") then
  30.                
  31.                 boolIris = not boolIris
  32.                 if boolIris == true then
  33.                     sg.closeIris()
  34.                 elseif boolIris == false then
  35.                     sg.openIris()
  36.                 end
  37.             end
  38.         -----------------
  39.         elseif side == "monitor_0" then
  40.             if (arg1 > 9 and arg1 < 21) and
  41.                (arg2 > 0 and arg2 < 3) then
  42.                AffichageSideScreen()
  43.                menuPrivate = false
  44.                mainMenu = true
  45.             elseif (arg1 > 1 and arg1 < 9) and
  46.                (arg2 > 1 and arg2 < 3) then
  47.                AffichageSideScreen()
  48.                mainMenu = false
  49.                menuPrivate = true
  50.             end
  51.         end
  52.     ------------------
  53.     end
  54. end
  55. function AffichageSideScreen()
  56.     monside.clear()
  57.     monside.setBackgroundColor(colors.black)
  58.     monside.setTextColor(colors.white)
  59.     monside.setCursorPos(1,1)
  60.     monside.write("O-------O           O-------O")
  61.     monside.setCursorPos(1,2)
  62.     monside.write("|       |           |       |")
  63.     monside.setCursorPos(1,3)
  64.     monside.write("|       O-----------O       |")
  65.     monside.setCursorPos(1,4)
  66.     monside.write("|       |           |       |")
  67.     monside.setCursorPos(1,5)
  68.     monside.write("|       |           |       |")
  69.     monside.setCursorPos(1,6)
  70.     monside.write("|       |           |       |")
  71.     monside.setCursorPos(1,7)
  72.     monside.write("|       |           |       |")
  73.     monside.setCursorPos(1,8)
  74.     monside.write("|       |           |       |")
  75.     monside.setCursorPos(1,9)
  76.     monside.write("|       |           |       |")
  77.     monside.setCursorPos(1,10)
  78.     monside.write("|       |           |       |")
  79.     monside.setCursorPos(1,11)
  80.     monside.write("|       |           |       |")
  81.     monside.setCursorPos(1,12)
  82.     monside.write("O-------O-----------O-------O")
  83.  
  84. monup.setBackgroundColor(colors.black)
  85. monup.clear()
  86. monside.setBackgroundColor(colors.black)
  87. monside.clear()
  88.  
  89. while true do
  90.  
  91.     TouchScreen()
  92.        state, engaged, direction = sg.stargateState()
  93.     irisState = sg.irisState()
  94.     address = sg.remoteAddress()
  95.     energy = math.floor(sg.energyAvailable() * 20)
  96.     --energyToDial = (sg.energyToDial(address) * 20)
  97.    
  98.     if energy > energyMax then
  99.         energy = energyMax
  100.     end
  101.    
  102.     local sgChevronEngaged, gate, chevNum, symbol
  103.    
  104.     -- AFFICHAGE ECRAN DU HAUT --
  105.     monup.setCursorPos(1,1)
  106.     monup.setTextColor(colors.white)
  107.     monup.setBackgroundColor(colors.lightGray)
  108.     monup.write("          Etat de la porte :           ")
  109.     monup.setBackgroundColor(colors.gray)
  110.     monup.setCursorPos(2,10)
  111.     monup.setTextColor(colors.white)
  112.     monup.write("Etat Iris :")
  113.     monup.setCursorPos(2,11)
  114.     monup.setBackgroundColor(colors.blue)
  115.     monup.write(" ")
  116.     monup.setCursorPos(12,11)
  117.     monup.write(" ")
  118.     monup.setCursorPos(3,11)
  119.     monup.setTextColor(colors.white)
  120.    
  121.     if irisState == "Closed" then
  122.         monup.setBackgroundColor(colors.red)
  123.         monup.write("  Fermé  ")
  124.     elseif irisState == "Closing" then
  125.         monup.setBackgroundColor(colors.orange)
  126.         monup.write("Fermeture")
  127.     elseif irisState == "Open" then
  128.         monup.setBackgroundColor(colors.green)
  129.         monup.write(" Ouvert  ")
  130.     elseif irisState == "Opening" then
  131.         monup.setBackgroundColor(colors.orange)
  132.         monup.write("Ouverture")
  133.     end
  134.    
  135.     monup.setBackgroundColor(colors.gray)
  136.     monup.setTextColor(colors.white)
  137.     monup.setCursorPos(14,10)
  138.     monup.write("Etat Porte  :")
  139.     monup.setBackgroundColor(colors.lightGray)
  140.     monup.setCursorPos(14,11)
  141.     monup.write(" ")
  142.     monup.setCursorPos(26,11)
  143.     monup.write(" ")
  144.     monup.setCursorPos(15,11)
  145.    
  146.     if state == "Idle" then
  147.         monup.setBackgroundColor(colors.green)
  148.         monup.write("   Prêt    ")
  149.     elseif state == "Dialling" then
  150.         monup.setBackgroundColor(colors.yellow)
  151.         monup.write("Composition")
  152.     elseif state == "Opening" then
  153.         monup.setBackgroundColor(colors.orange)
  154.         monup.write(" Ouverture ")
  155.     elseif state == "Connected" then
  156.         monup.setBackgroundColor(colors.green)
  157.         monup.write(" Connecté  ")
  158.     elseif state == "Closing" then
  159.         monup.setBackgroundColor(colors.orange)
  160.         monup.write(" Fermeture ")
  161.     elseif state == "Offline" then
  162.         monup.setBackgroundColor(colors.red)
  163.         monup.write("Déconnecté ")
  164.     end
  165.    
  166.     monup.setCursorPos(28,3)
  167.     monup.setBackgroundColor(colors.gray)
  168.     monup.write("Chevrons  :")
  169.     monup.setBackgroundColor(colors.lightGray)
  170.     monup.setCursorPos(28,4)
  171.     monup.write(" ")
  172.     monup.setCursorPos(38,4)
  173.     monup.write(" ")
  174.     if (state == "Dialing" or state == "Closing") then
  175.         monup.setBackgroundColor(colors.orange)
  176.     else
  177.         monup.setBackgroundColor(colors.green)
  178.     end
  179.     monup.setCursorPos(29,4)
  180.     monup.write("  "..engaged.." / 9  ")
  181.    
  182.     monup.setCursorPos(28,6)
  183.     monup.setBackgroundColor(colors.gray)
  184.     monup.write("Direction :")
  185.     monup.setBackgroundColor(colors.lightGray)
  186.     monup.setCursorPos(28,7)
  187.     monup.write(" ")
  188.     monup.setCursorPos(38,7)
  189.     monup.write(" ")
  190.    
  191.     monup.setCursorPos(29,7)
  192.     if direction == "Outgoing" then
  193.         monup.setBackgroundColor(colors.green)
  194.         monup.write(" Sortant ")
  195.     elseif direction == "Incoming" then
  196.         monup.setBackgroundColor(colors.red)
  197.         monup.write(" Entrant ")
  198.     elseif direction == "" then
  199.         monup.setBackgroundColor(colors.orange)
  200.         monup.write(" Aucune  ")
  201.     end
  202.    
  203.     monup.setBackgroundColor(colors.gray)
  204.     monup.setCursorPos(28,9)
  205.     monup.write("Composer  :")
  206.     monup.setBackgroundColor(colors.blue)
  207.     monup.setCursorPos(28,10)
  208.     monup.write(" ")
  209.     monup.setCursorPos(28,11)
  210.     monup.write(" ")
  211.     monup.setCursorPos(38,10)
  212.     monup.write(" ")
  213.     monup.setCursorPos(38,11)
  214.     monup.write(" ")
  215.     monup.setBackgroundColor(colors.green)
  216.     monup.setCursorPos(29,10)
  217.     monup.write("  Prêt   ")
  218.     monup.setCursorPos(29,11)
  219.     monup.write("         ")
  220.    
  221.     monup.setBackgroundColor(colors.lightGray)
  222.     monup.setCursorPos(2,6)
  223.     monup.write("  Energie de la porte :  ")
  224.     monup.setBackgroundColor(colors.gray)
  225.     monup.setCursorPos(2,7)
  226.     monup.write("Disponible:")
  227.    
  228.     monup.setBackgroundColor(colors.lightGray)
  229.     monup.setCursorPos(2,8)
  230.     monup.write("           ")
  231.     monup.setBackgroundColor(colors.green)
  232.     monup.setCursorPos(3,8)
  233.     monup.write("         ")
  234.     monup.setCursorPos(3,8)
  235.     monup.setTextColor(colors.yellow)
  236.     monup.write(tostring(energy))
  237.     monup.setCursorPos(10,8)
  238.     monup.setTextColor(colors.red)
  239.     monup.write("EU")    
  240.    
  241.     monup.setCursorPos(14,7)
  242.     monup.setBackgroundColor(colors.gray)
  243.     monup.setTextColor(colors.white)
  244.     monup.write("Nécessaire  :")
  245.     monup.setBackgroundColor(colors.lightGray)
  246.     monup.setCursorPos(14,8)
  247.     monup.write("             ")
  248.     monup.setBackgroundColor(colors.green)
  249.     monup.setCursorPos(15,8)
  250.     monup.write("           ")
  251.     monup.setCursorPos(24,8)
  252.     monup.setTextColor(colors.red)
  253.     monup.write("EU")
  254.    
  255.     monup.setCursorPos(2,3)
  256.     monup.setBackgroundColor(colors.gray)
  257.     monup.write("                         ")
  258.     monup.setCursorPos(2,3)
  259.     monup.setTextColor(colors.white)
  260.     monup.write("Composition de la porte :")
  261.    
  262.     -----------------------------
  263.    
  264.     -- AFFICHAGE ECRAN UP --
  265.     monup.setBackgroundColor(colors.black)
  266.     monup.setTextColor(colors.white)
  267.     monup.setCursorPos(1,2)
  268.     monup.write("--------------------------O------------")
  269.     monup.setCursorPos(27,3)
  270.     monup.write("|")
  271.     monup.setCursorPos(27,4)
  272.     monup.write("|")
  273.     monup.setCursorPos(27,5)
  274.     monup.write("|")
  275.     monup.setCursorPos(27,6)
  276.     monup.write("|")
  277.     monup.setCursorPos(27,7)
  278.     monup.write("|")
  279.     monup.setCursorPos(27,8)
  280.     monup.write("|")
  281.     monup.setCursorPos(27,9)
  282.     monup.write("|")
  283.     monup.setCursorPos(27,10)
  284.     monup.write("|")
  285.     monup.setCursorPos(27,11)
  286.     monup.write("|")
  287.     monup.setCursorPos(27,12)
  288.     monup.write("|")
  289.     ------------------------
  290.    
  291.     -- AFFICHAGE ECRAN SIDE --
  292.     monside.setTextColor(colors.green)
  293.     monside.setCursorPos(11,1)
  294.     monside.write("Stargate")
  295.     monside.setCursorPos(14,2)
  296.     monside.write("DHD")
  297.     -- PARTIE GAUCHE --
  298.     monside.setCursorPos(2,2)
  299.     monside.setBackgroundColor(colors.blue)
  300.     monside.setTextColor(colors.white)
  301.     monside.write("Private")
  302.     -------------------
  303.     -- PARTIE CENTRALE --
  304.     if mainMenu == true then
  305.         monside.setCursorPos(10,4)
  306.         monside.setBackgroundColor(colors.green)
  307.         monside.write("   Menu    ")
  308.         monside.setCursorPos(10,5)
  309.         monside.write("Principale ")
  310.     end
  311.     ---------------------
  312.     -- PARTIE DROITE --
  313.    
  314.     -------------------
  315.     --------------------------
  316.    
  317.     sleep(0.05)
  318. end
Advertisement
Add Comment
Please, Sign In to add comment