Advertisement
sshikamaru

fusion 2 ecrans

Feb 28th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 35.67 KB | None | 0 0
  1. local computer = require("computer")
  2. local component = require("component")
  3. local term = require("term")
  4. local math = require("math")
  5. local event = require("event")
  6. local string = require("string")
  7. local unicode = require("unicode")
  8. local color = require("colors")
  9. local side = require("sides")
  10. local serialization = require("serialization")
  11.  
  12. --Récupération des écrans et GPU
  13. local screen1 = component.get("4e22","screen")
  14. local screen2 = component.get("0d79","screen")
  15. local pgpus = {}
  16. pgpus[1] = component.proxy(component.get("de87","gpu"))
  17. pgpus[2] = component.proxy(component.get("9e8a","gpu"))
  18. pgpus[2].bind(screen2)
  19. pgpus[1].bind(screen1)
  20. pgpus[1].setResolution(100,50)
  21. pgpus[2].setResolution(100,50)
  22.  
  23. --Récupération des composants
  24. local modem = component.modem
  25. local rs = component.redstone
  26. local fusion = component.reactor_logic_adapter
  27. local laser1 = component.proxy(component.get("31d4","laser_amplifier"))
  28. local laser2 = component.proxy(component.get("4628","laser_amplifier"))
  29. local cmd = side.top
  30. local DTd = side.east
  31. local DTg = side.west
  32.  
  33. --définition des variables
  34. local lancement = 600000000
  35. local ratio_fusion = 0
  36. local alim_fusion_dtfuel_value = 0
  37. local charge_laser = false
  38. local charge_laser1 = false
  39. local charge_laser2 = false
  40. local alim_fusion = false
  41. local alim_fusion_tritium = false
  42. local alim_fusion_deuterium = false
  43. local alim_cuve_gauche_dtfuel = false
  44. local alim_cuve_droite_dtfuel = false
  45. local activation_laser_amplifier = false
  46. local laser_pret = false
  47. local alim_dtfuel_tritium = false
  48. local alim_dtfuel_deuterium = false
  49. local table_bit = {
  50.   false, -- 1 charge_laser
  51.   false, -- 2 charge_laser1
  52.   false, -- 3 charge_laser2
  53.   false, -- 4 alim_fusion
  54.   false, -- 5 alim_fusion_tritium
  55.   false, -- 6 alim_fusion_deuterium
  56.   false, -- 7 alim_cuve_gauche_dtfuel
  57.   false, -- 8 alim_cuve_droite_dtfuel
  58.   false, -- 9 activation_laser_amplifier
  59.   false, -- 10 laser_pret
  60.   false, -- 11 alim_dtfuel_tritium
  61.   false -- 12 alim_dtfuel_deuterium
  62. }
  63. local table_bit2 = {}
  64. local function bit_in_variables()
  65.   charge_laser = table_bit[1]
  66.   charge_laser1 = table_bit[2] and charge_laser
  67.   charge_laser2 = table_bit[3] and charge_laser
  68.   alim_fusion = table_bit[4]
  69.   alim_fusion_tritium = table_bit[5]
  70.   alim_fusion_deuterium = table_bit[6]
  71.   alim_cuve_gauche_dtfuel = table_bit[7]
  72.   alim_cuve_droite_dtfuel = table_bit[8]
  73.   activation_laser_amplifier = table_bit[9]
  74.   laser_pret = table_bit[10]
  75.   alim_dtfuel_tritium = table_bit[11]
  76.   alim_dtfuel_deuterium = table_bit[12]
  77. end
  78.  
  79. local table_rotary = {}
  80. local i = 0
  81. for i = 0, 23 do
  82.   local text = "Rotary n°"..tostring(i)
  83.   local v1 = false
  84.   table_rotary[i] = {label=text,bit=v1}
  85. end
  86. local test1 = false
  87. local test2 = false
  88. local noir = 0x000000
  89. local blanc = 0xFFFFFF
  90. local rouge = 0xFF0000
  91. local vert = 0x00FF00
  92. local bleu = 0x0000FF
  93. local cyan = 0x00FFFF
  94. local jaune = 0xFFFF00
  95. local magenta = 0xFF00FF
  96. local violet = 0xBE00FF
  97. local orange = 0xFF9143
  98.  
  99. --initialisation de la redstone
  100. for i = 0, 15 do
  101. rs.setBundledOutput(cmd,i,255)
  102. rs.setBundledOutput(DTg,i,255)
  103. rs.setBundledOutput(DTd,i,255)
  104. end
  105.  
  106. --Récupération des tanks
  107. local tank_tritium = component.proxy(component.get("ce22","tank_controller"))
  108. local tank_deuterium = component.proxy(component.get("3e03","tank_controller"))
  109. local tank_dtg = component.proxy(component.get("7957","tank_controller"))
  110. local tank_dtd = component.proxy(component.get("4803","tank_controller"))
  111. local tank = {{tank_tritium,color=0x0000ff},{tank_deuterium,color=0xff0000},{tank_dtg,color=0xff00ff},{tank_dtd,color=0xff00ff}}
  112.  
  113. --Ouverture des ports
  114. modem.open(10001)
  115.  
  116. --Fonctions
  117. local function setColor(bg,fg,gpu)
  118.   pgpus[gpu].setBackground(bg)
  119.   pgpus[gpu].setForeground(fg)
  120. end
  121.  
  122.  local function unit(qty)
  123.   if qty >= 1000000000 then
  124.     return string.format("%.02f MB",qty/10000000)
  125.   elseif qty >=1000000 then
  126.     return string.format("%.02f KB",qty/1000000)
  127.   elseif qty >=1000 then
  128.     return string.format("%.02f B ",qty/1000)
  129.   else
  130.     return string.format("%d mB",qty)
  131.   end
  132. end
  133.  
  134. local function unitrf(qty)
  135.   if qty >= 1000000000000000 or qty <= -1000000000000000 then
  136.     return string.format("%.03f PRF",qty/1000000000000000)
  137.   elseif qty >= 1000000000000 or qty <= -1000000000000 then
  138.     return string.format("%.03f TRF",qty/1000000000000)
  139.   elseif qty >=1000000000 or qty <= -1000000000 then
  140.     return string.format("%.03f GRF",qty/1000000000)
  141.   elseif qty >=1000000 or qty <= -1000000 then
  142.     return string.format("%.03f MRF",qty/1000000)
  143.   elseif qty >=1000 or qty <= -1000 then
  144.     return string.format("%.03f kRF",qty/1000)
  145.   else
  146.     return string.format("%.03f RF ",qty)
  147.   end
  148. end
  149.  
  150. function loadbar(x,y,width,cur,text,bg,fg,gpu)
  151.   local raw = " " .. text ..string.rep(" ", width - unicode.len(text) - 2) .. " "
  152.   local oldbg = pgpus[gpu].setBackground(bg)
  153.   local oldfg = pgpus[gpu].setForeground(fg)
  154.   pgpus[gpu].set(x,y,unicode.sub(raw,1,cur))
  155.   pgpus[gpu].setBackground(oldbg)
  156.   pgpus[gpu].setForeground(oldfg)
  157.   pgpus[gpu].set(x+cur,y,unicode.sub(raw,cur+1,width))
  158. end
  159.  
  160. local function afftank(x,y,length,ntank,gpu)
  161.   local amount = tank[ntank][1].getFluidInTank(0)[1].amount
  162.   local capacity = tank[ntank][1].getFluidInTank(0)[1].capacity
  163.   local label = tank[ntank][1].getFluidInTank(0)[1].label
  164.   local pct = amount / capacity
  165.   local cur = math.floor(pct * length)
  166.   local bg = tank[ntank].color
  167.   local fg = blanc - bg
  168.   local textfrac = string.format("%s / %s", unitrf(amount), unitrf(capacity))
  169.   local textpct = string.format("%.02f%%", pct*100)
  170.   local text1 = "          "..label
  171.   local text2 = ""
  172.   local text3 = textfrac .. string.rep(" ", length - string.len(textfrac) - string.len(textpct) - 2) .. textpct
  173.   loadbar(x,y,length,cur,text1,bg,fg,gpu)
  174.   loadbar(x,y+1,length,cur,text2,bg,fg,gpu)
  175.   loadbar(x,y+2,length,cur,text3,bg,fg,gpu)
  176. end  
  177.  
  178. local function affenergie(x,y,length,tableau,gpu)
  179.   local amount = tableau[1] * 0.4
  180.   local capacity = tableau[2] * 0.4
  181.   local pct = amount / capacity
  182.   local color = cyan
  183.   local color2 = rouge
  184.   local cur = math.floor(pct * length)
  185.   local textfrac = string.format("%s / %s", unitrf(amount), unitrf(capacity))
  186.   local textpct = string.format("%.02f%%", pct*100)
  187.   local text1 = "        ENERGIE DANS LA BATTERIE MEKANISM "
  188.   local text2 = ""
  189.   local text3 = textfrac .. string.rep(" ", length - string.len(textfrac) - string.len(textpct) - 2) .. textpct
  190.   loadbar(x,y,length,cur,text1,color,color2,gpu)
  191.   loadbar(x,y+1,length,cur,text2,color,color2,gpu)
  192.   loadbar(x,y+2,length,cur,text3,color,color2,gpu)
  193. end
  194.  
  195. local function afflaser(x,y,length,amount,capacity,gpu)
  196.   local pct = amount / capacity
  197.   local color = 0x0000FF
  198.   local color2 = 0xFFFF00
  199.   local cur = math.floor(pct * length)
  200.   local cur2 = math.floor(lancement / capacity * length)-1
  201.   local textfrac = string.format("%s / %s", unitrf(amount), unitrf(capacity))
  202.   local textpct = string.format("%.02f%%", pct*100)
  203.   local texte_laser1
  204.   local texte_laser2
  205.   if amount == capacity then
  206.     texte_laser1 = "Chargé totalement"
  207.   elseif charge_laser == false then
  208.     texte_laser1 = "En attente de charge"
  209.   elseif charge_laser == true then
  210.     if charge_laser1 == false and charge_laser2 == false then
  211.       texte_laser1 = "En attente de charge"
  212.     else
  213.       texte_laser1 = "En  charge"
  214.     end
  215.   end
  216.   if amount < lancement then
  217.     texte_laser2 = " - Lancement impossible"
  218.   elseif amount >= lancement then
  219.     texte_laser2 = " - Lancement possible"
  220.   end
  221.   texte_palier = "│  Palier de lancement minimum : "..unitrf(lancement)
  222.   local text1 = " Charge du Laser Amplifier - "..texte_laser1..texte_laser2
  223.   local text2 = textfrac .. string.rep(" ", cur2  - string.len(textfrac)) .. texte_palier .. string.rep(" ", length - cur2 - string.len(texte_palier) - string.len(textpct) - 0) .. textpct
  224.   loadbar(x,y,length,cur,text1,color,color2,gpu)
  225.   loadbar(x,y+1,length,cur,text2,color,color2,gpu)
  226. end
  227.  
  228. local function lvl_deut(x,y,length,ntank,gpu)
  229.   local amount = tank[ntank][1].getFluidInTank(0)[1].amount
  230.   local capacity = tank[ntank][1].getFluidInTank(0)[1].capacity
  231.   local pct = amount / capacity
  232.   local cur = math.floor(pct * length)
  233.   local bg = tank[ntank].color
  234.   local fg = blanc - bg
  235.   local text = ntank.." : "..unit(amount)
  236.   loadbar(x,y,length,cur,text,bg,fg,gpu)
  237. end
  238.  
  239. local function barre_verticale(x,y,hauteur,largeur,entete,ntank,color1,color2,gpu)
  240.   local k = 0
  241.   local amount = tank[ntank][1].getFluidInTank(0)[1].amount
  242.   local capacity = tank[ntank][1].getFluidInTank(0)[1].capacity
  243.   local cur = math.floor((amount / capacity) * hauteur)
  244.   local dir = string.rep(" ",largeur)
  245.   for k = 1, hauteur do
  246.     local vy = y + hauteur - k
  247.     if k <= cur then
  248.       setColor(color1,color2,gpu)
  249.     elseif k > cur then
  250.       setColor(noir,blanc,gpu)  
  251.     end
  252.       pgpus[gpu].set(x,vy,dir)
  253.     if k == 1 then
  254.       pgpus[gpu].set(x,vy,dir)
  255.       pgpus[gpu].set(x,vy,"  Max "..unit(capacity))
  256.     elseif k == 3 then
  257.       pgpus[gpu].set(x,vy,dir)
  258.       pgpus[gpu].set(x,vy,"  Cur "..unit(amount))
  259.     elseif k == 4 then
  260.       pgpus[gpu].set(x,vy,dir)
  261.       pgpus[gpu].set(x,vy,string.format("  Cur %06.02f%%  ",(amount/capacity)*100))
  262.     elseif k == hauteur then
  263.       pgpus[gpu].set(x,vy,entete)
  264.     end
  265.     setColor(noir,blanc,gpu)
  266.   end
  267. end
  268.  
  269. local function bouton(x,y,etat,text,color,color2,gpu)
  270.   if etat == true then
  271.     setColor(color,color2,gpu)
  272.     pgpus[gpu].set(x,y," "..text.." ")
  273.     setColor(noir,blanc,gpu)
  274.   elseif etat == false then
  275.     setColor(color2,color,gpu)
  276.     pgpus[gpu].set(x,y," "..text.." ")
  277.     setColor(noir,blanc,gpu)
  278.   end
  279. end
  280.  
  281. local function bouton_rotary(x,y,netat,gpu)
  282.   local text
  283.     if table_rotary[netat].bit == true then
  284.       text = "ON "
  285.     bouton(x,y,table_rotary[netat].bit,text,vert,noir,gpu)
  286.     elseif table_rotary[netat].bit == false then
  287.       text = "OFF"
  288.     bouton(x,y,table_rotary[netat].bit,text,rouge,noir,gpu)
  289.     end
  290. end
  291.  
  292. local function boutonx2(x,y,x2,y2,nbit,text1,text2,color1,color2,color3,color4,espace,gpu)
  293.   if x2 > x-1 and x2 < x+string.len(text1)+2 and y2 == y then
  294.     table_bit[nbit] = true
  295.   elseif x2 > x+string.len(text1)+2 and x2 < x+string.len(text1)+string.len(text2)+5 and y2 == y then
  296.     table_bit[nbit] = false
  297.   end
  298.   pgpus[2].set(4+10*(nbit-1),9,tostring(nbit).." : "..tostring(table_bit[nbit]).." ")
  299.   bouton(x,y,table_bit[nbit],text1,color1,color2,gpu)
  300.   bouton(x+string.len(text1)+2+espace,y,not(table_bit[nbit]),text2,color3,color4,gpu)
  301. end
  302.  
  303. local function afflasers(x,y,length,gpu)
  304.   local amount1 = laser1.getEnergy() * 0.4
  305.   local capacity1 = laser1.getMaxEnergy() * 0.4
  306.   local amount2 = laser2.getEnergy() * 0.4
  307.   local capacity2 = laser2.getMaxEnergy() * 0.4
  308.   afflaser(x,y,length,amount1,capacity1,gpu)
  309.   afflaser(x,y+3,length,amount2,capacity2,gpu)
  310. end
  311.  
  312. local function conversion_binaire_nombre(etat)
  313.   if etat == false then
  314.     return 255
  315.   elseif etat == true then
  316.     return 0
  317.   end
  318. end
  319.  
  320. local function conversion_nombre_binaire(etat)
  321.   if etat == 0 then
  322.     return true
  323.   elseif etat > 0 then
  324.     return false
  325.   end
  326. end
  327.  
  328. local function affrotaryx24(x,y,gpu)
  329.   local etat
  330.   local i
  331.   for i = 0, 23 do
  332.     if i <= 5 then
  333.       bouton_rotary(x-8*(i),15,i,gpu)
  334.     elseif i > 5 and i <= 11 then
  335.       bouton_rotary(x-8*(i-6),39,i,gpu)
  336.     elseif i > 11 and i <= 17 then
  337.       bouton_rotary(x+9+8*(i-12),15,i,gpu)
  338.     elseif i > 17 and i <= 23 then
  339.       bouton_rotary(x+9+8*(i-18),39,i,gpu)
  340.     end
  341.   end
  342. end
  343.  
  344. local function aff_pourcent(gpu)
  345.   setColor(bleu,blanc,gpu)
  346.   local alim_pct = alim_fusion_dtfuel_value / 24
  347.   pgpus[gpu].set(26,22,string.format("%06.02f%%", alim_pct*100))
  348.   setColor(noir,blanc,gpu)
  349.  
  350.   if alim_fusion == false then
  351.     setColor(orange,noir,gpu)
  352.     pgpus[gpu].set(48,31,string.format("%06.02f%%", ratio_fusion))
  353.     setColor(noir,blanc,gpu)
  354.   elseif alim_fusion == true then
  355.     pgpus[gpu].set(48,31,"-------")
  356.   end
  357. end
  358.  
  359. local function cmd_rotary()
  360. local i
  361.   for i = 0, 24 do
  362.     if i < alim_fusion_dtfuel_value then
  363.       if i < 12 then
  364.         rs.setBundledOutput(DTg,i,0)
  365.       elseif i >= 12 then
  366.         rs.setBundledOutput(DTd,i-12,0)
  367.       end
  368.     elseif i >= alim_fusion_dtfuel_value then
  369.       if i < 12 then
  370.         rs.setBundledOutput(DTg,i,255)
  371.       elseif i >= 12 then
  372.         rs.setBundledOutput(DTd,i-12,255)
  373.       end
  374.     end
  375.   end
  376. end
  377.  
  378. local function tables_differentes()
  379.   if table_bit ~= table_bit2 then
  380.     rs.setBundledOutput(cmd,0,conversion_binaire_nombre(charge_laser1))  -- laser gauche
  381.     rs.setBundledOutput(cmd,1,conversion_binaire_nombre(charge_laser2))  -- laser droite
  382.     rs.setBundledOutput(cmd,2,conversion_binaire_nombre(alim_fusion_deuterium))  -- alim fusion en deutérium
  383.     rs.setBundledOutput(cmd,3,conversion_binaire_nombre(alim_fusion_tritium))  -- alim fusion en tritium
  384.     rs.setBundledOutput(cmd,4,conversion_binaire_nombre(alim_fusion))  -- alim fusion dt-fuel ou deut-trit
  385.     rs.setBundledOutput(cmd,5,conversion_binaire_nombre(not(alim_fusion)))  -- alim fusion dt-fuel ou deut-trit
  386.     rs.setBundledOutput(cmd,6,conversion_binaire_nombre(alim_cuve_gauche_dtfuel))  -- alim cuve gauche dt-fuel
  387.     rs.setBundledOutput(cmd,7,conversion_binaire_nombre(alim_cuve_droite_dtfuel))  -- alim cuve droite dt-fuel
  388.     rs.setBundledOutput(cmd,8,conversion_binaire_nombre(activation_laser_amplifier))  -- activation laser amplifier - lancement fusion
  389.     rs.setBundledOutput(cmd,9,conversion_binaire_nombre(laser_pret))  -- laser_pret
  390.     --rs.setBundledOutput(cmd,10,conversion_binaire_nombre())  --
  391.     rs.setBundledOutput(cmd,11,conversion_binaire_nombre(alim_dtfuel_tritium))  -- alim machinerie dt-fuel en tritium
  392.     --rs.setBundledOutput(cmd,12,conversion_binaire_nombre())  --
  393.     --rs.setBundledOutput(cmd,13,conversion_binaire_nombre())  --
  394.     rs.setBundledOutput(cmd,14,conversion_binaire_nombre(alim_dtfuel_deuterium))  -- alim machinerie dt-fuel en deutérium
  395.     --rs.setBundledOutput(cmd,15,conversion_binaire_nombre())  --    
  396.   end
  397.   aff_pourcent(2)
  398.   bit_in_variables()
  399.   table_bit2 = table_bit
  400. end
  401.  
  402.  
  403. --Matrices
  404.  pgpus[1].set(1,1,"╔Ecran n°1═════════════════════════════════════════════════════════════════════════════════════════╗")
  405.  pgpus[1].set(1,2,"║                                                                                                  ║")
  406.  pgpus[1].set(1,3,"╠══════════════════════════════════════════════════════════════════════════════════════════════════╣")
  407.  pgpus[1].set(1,4,"║                     ETAT DES RESERVOIRS DE FLUIDES POUR LE REACTEUR A FUSION                     ║")
  408.  pgpus[1].set(1,5,"╟──────────────────────────────────────────────────────────────────────────────────────────────────╢")
  409.  pgpus[1].set(1,6,"║                                                                                                  ║")
  410.  pgpus[1].set(1,7,"║                                                                                                  ║")
  411.  pgpus[1].set(1,8,"║                                                                                                  ║")
  412.  pgpus[1].set(1,9,"╟──────────────────────────────────────────────────────────────────────────────────────────────────╢")
  413. pgpus[1].set(1,10,"║                                                                                                  ║")
  414. pgpus[1].set(1,11,"║                                                                                                  ║")
  415. pgpus[1].set(1,12,"║                                                                                                  ║")
  416. pgpus[1].set(1,13,"╟──────────────────────────────────────────────────────────────────────────────────────────────────╢")
  417. pgpus[1].set(1,14,"║                                                                                                  ║")
  418. pgpus[1].set(1,15,"║                                                                                                  ║")
  419. pgpus[1].set(1,16,"║                                                                                                  ║")
  420. pgpus[1].set(1,17,"╟──────────────────────────────────────────────────────────────────────────────────────────────────╢")
  421. pgpus[1].set(1,18,"║                                                                                                  ║")
  422. pgpus[1].set(1,19,"║                                                                                                  ║")
  423. pgpus[1].set(1,20,"║                                                                                                  ║")
  424. pgpus[1].set(1,21,"╠══════════════════════════════════════════════════════════════════════════════════════════════════╣")
  425. pgpus[1].set(1,22,"║                                                                                                  ║")
  426. pgpus[1].set(1,23,"║                                                                                                  ║")
  427. pgpus[1].set(1,24,"║                                                                                                  ║")
  428. pgpus[1].set(1,25,"║                                                                                                  ║")
  429. pgpus[1].set(1,26,"║                                                                                                  ║")
  430. pgpus[1].set(1,27,"║                                                                                                  ║")
  431. pgpus[1].set(1,28,"║                                                                                                  ║")
  432. pgpus[1].set(1,29,"║                                                                                                  ║")
  433. pgpus[1].set(1,30,"║                                                                                                  ║")
  434. pgpus[1].set(1,31,"║                                                                                                  ║")
  435. pgpus[1].set(1,32,"║                                                                                                  ║")
  436. pgpus[1].set(1,33,"║                                                                                                  ║")
  437. pgpus[1].set(1,34,"║                                                                                                  ║")
  438. pgpus[1].set(1,35,"║                                                                                                  ║")
  439. pgpus[1].set(1,36,"║                                                                                                  ║")
  440. pgpus[1].set(1,37,"║                                                                                                  ║")
  441. pgpus[1].set(1,38,"║                                                                                                  ║")
  442. pgpus[1].set(1,39,"║                                                                                                  ║")
  443. pgpus[1].set(1,40,"║                                                                                                  ║")
  444. pgpus[1].set(1,41,"║                                                                                                  ║")
  445. pgpus[1].set(1,42,"║                                                                                                  ║")
  446. pgpus[1].set(1,43,"║                                                                                                  ║")
  447. pgpus[1].set(1,44,"║                                                                                                  ║")
  448. pgpus[1].set(1,45,"║                                                                                                  ║")
  449. pgpus[1].set(1,46,"╠══════════════════════════════════════════════════════════════════════════════════════════════════╣")
  450. pgpus[1].set(1,47,"║                                                                                                  ║")
  451. pgpus[1].set(1,48,"║                                                                                                  ║")
  452. pgpus[1].set(1,49,"║                                                                                                  ║")
  453. pgpus[1].set(1,50,"╚══════════════════════════════════════════════════════════════════════════════════════════════════╝""ON","OFF",vert,noir,rouge,noir,1,2)
  454.   boutonx2(24,32,x,y,2,"ON","OFF",vert,noir,rouge,noir,2,2)
  455.   boutonx2(67,32,x,y,3,"ON","OFF",vert,noir,rouge,noir,2,2)
  456.   boutonx2(20,43,x,y,4,"D-T Fuel","Deutérium-Tritium",violet,noir,jaune,noir,1,2)
  457. end
  458.  
  459. affboutons(2,1)
  460. affrotaryx24(44,15,2)
  461. aff_pourcent(2)
  462.  
  463. local function onModem(_,_,from,port,_,IDcodes,message)
  464.   if IDcodes == "batterie générale" then
  465.     value_receive = serialization.unserialize(message)
  466.     affenergie(2,47,98,value_receive,1)
  467.   end    
  468. end
  469.  
  470. local function onRedstone(event,address,side,value)
  471.   if side == 4 or side == 5 then
  472.     affrotaryx24(44,15,2)
  473.   end
  474. end
  475.  
  476. local function onTouch(event,address,x,y,clic,pseudo)
  477.   local tclic
  478.   if clic == 0  then
  479.     tclic = "Clic gauche"
  480.   elseif clic == 1 then
  481.     tclic = "Clic droit"
  482.   else
  483.     tclic = "Clic inconnu"
  484.   end
  485.   local ecran = ""
  486.   if address == screen1 then
  487.     ecran = "1"
  488.   elseif address == screen2 then
  489.     ecran = "2"
  490.   else
  491.     ecran = "?"
  492.   end
  493.   pgpus[1].set(2,2,"                                                                                                  ")
  494.   pgpus[1].set(5,2," "..tclic.." de la part de "..pseudo.." / X : "..string.format("% 3s",x).." / Y : "..string.format("% 3s",y).." sur l'écran n°"..ecran)
  495.   pgpus[2].set(2,2,"                                                                                                  ")
  496.   pgpus[2].set(5,2," "..tclic.." de la part de "..pseudo.." / X : "..string.format("% 3s",x).." / Y : "..string.format("% 3s",y).." sur l'écran n°"..ecran)
  497.   if address == screen1 then
  498.     if x~=1 and y~=1 then
  499.       if x>13 and x<31 and y>4 and y<13 then
  500.       elseif x>44 and x<62 and y>22 and y<31 then
  501.       end
  502.     elseif x==1 and y==1 then
  503.       computer.pushSignal("quit")
  504.       term.setCursor(1,1)
  505.       return false
  506.     end
  507.   elseif address==screen2 then
  508.     if x~=1 and y~=1 then
  509.       affboutons(x,y)
  510.       if y==22 then
  511.         if x>22 and x<26 then
  512.           alim_fusion_dtfuel_value = alim_fusion_dtfuel_value + 1
  513.           if alim_fusion_dtfuel_value > 24 then
  514.             alim_fusion_dtfuel_value = 24
  515.           end
  516.           aff_pourcent(2)
  517.         elseif x>32 and x<36 then
  518.           alim_fusion_dtfuel_value = alim_fusion_dtfuel_value - 1
  519.           if alim_fusion_dtfuel_value < 0 then
  520.             alim_fusion_dtfuel_value = 0
  521.           end
  522.           aff_pourcent(2)
  523.         end
  524.         cmd_rotary()
  525.       elseif y==31 then
  526.         if x>45 and x<47 then
  527.           ratio_fusion = ratio_fusion + 1
  528.           if ratio_fusion > 100 then
  529.             ratio_fusion = 100
  530.           end
  531.           aff_pourcent(2)
  532.         elseif x>55 and x<57 then
  533.           ratio_fusion = ratio_fusion - 1
  534.           if ratio_fusion < 0 then
  535.             ratio_fusion = 0
  536.           end
  537.           aff_pourcent(2)
  538.         end
  539.       end
  540.     elseif x==1 and y==1 then
  541.       computer.pushSignal("quit")
  542.       term.setCursor(1,1)
  543.       return false
  544.     end
  545.   end
  546. end
  547.  
  548. local function onTimer(_,timer)
  549.   lvl_deut(65,21,15,3,2)
  550.   lvl_deut(65,22,15,4,2)
  551.   afftank(2,6,98,1,1)
  552.   afftank(2,10,98,2,1)
  553.   afftank(2,14,98,3,1)
  554.   afftank(2,18,98,4,1)
  555.   barre_verticale(4,22,11,15,"    TRITIUM    ",3,bleu,jaune,2)
  556.   barre_verticale(83,22,11,15,"   DEUTERIUM   ",3,rouge,vert,2)
  557.   afflasers(2,45,98,2)
  558.   tables_differentes()
  559.   return true
  560. end
  561.  
  562. event.listen("touch",onTouch)
  563. event.listen("modem_message",onModem)
  564. local timer = event.timer(.1,onTimer,math.huge)
  565. event.listen("redstone_changed", onRedstone)
  566. event.pull("quit")
  567. event.cancel(timer)
  568. event.ignore("touch",onTouch)
  569. event.ignore("modem_message",onModem)
  570. event.ignore("redstone_changed", onRedstone)
  571. modem.close(10001)
  572.  
  573. setColor(noir,blanc,1)
  574. setColor(noir,blanc,2)
  575. pgpus[1].setResolution(160,50)
  576. pgpus[2].setResolution(160,50)
  577. pgpus[2].fill(1,1,160,50," ")
  578. pgpus[1].fill(1,1,160,50," ")
  579.  
  580. --Créé par sshikamaru. Vous avez le droit de l'utiliser mais pas de le distribuer.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement