Advertisement
sshikamaru

fusion 1 ecran

Feb 28th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.23 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 écran et GPU
  13. local screen = component.getPrimary("screen")
  14. local gpu = component.gpu
  15. gpu.setResolution(100,50)
  16.  
  17. --définition des couleurs
  18. local noir = 0x000000
  19. local blanc = 0xFFFFFF
  20. local rouge = 0xFF0000
  21. local vert = 0x00FF00
  22. local bleu = 0x0000FF
  23. local cyan = 0x00FFFF
  24. local jaune = 0xFFFF00
  25. local magenta = 0xFF00FF
  26. local violet = 0xBE00FF
  27. local orange = 0xFF9143
  28.  
  29. --Récupération des composants
  30. local rs = component.redstone
  31. local fusion = component.reactor_logic_adapter
  32. local laser1 = component.getPrimary("laser_amplifier")
  33. local cmd = side.top
  34. local DTf = side.east
  35. local alm = side.bottom
  36. local tank_tritium = component.proxy(component.get("0351","tank_controller"))
  37. local tank_deuterium = component.proxy(component.get("3cff","tank_controller"))
  38. local tank_dtf = component.proxy(component.get("0057","tank_controller"))
  39. local tank = {{tank_tritium,color=bleu},{tank_deuterium,color=rouge},{tank_dtf,color=violet}}
  40.  
  41. --définition des variables
  42. local lancement = 1000000000
  43. local ratio_fusion = 0
  44. local alim_fusion_dtfuel_value = 0
  45. local etape_demarrage = 0
  46. local decompte_max = 10
  47. local decompte = decompte_max
  48. local table_bit = {
  49.   false, -- 1 charge_laser
  50.   false, -- 2 charge_laser1
  51.   false, -- 3
  52.   false, -- 4 alim_fusion
  53.   false, -- 5 alim_fusion_tritium
  54.   false, -- 6 alim_fusion_deuterium
  55.   false, -- 7 alim_cuve_dtfuel
  56.   false, -- 8
  57.   false, -- 9 activation_laser_amplifier
  58.   false, -- 10 alarmes activées/désactivées
  59.   false, -- 11 alim_dtfuel_tritium
  60.   false, -- 12 alim_dtfuel_deuterium
  61.   false, -- 13 laser chargés
  62.   false, -- 14 démarrage auto
  63.   false, -- 15
  64.   false --
  65. }
  66. local table_rotary = {}
  67. local i = 0
  68. for i = 0, 12 do
  69.   local text = "Rotary n°"..tostring(i)
  70.   local v1 = false
  71.   table_rotary[i] = {label=text,bit=v1}
  72. end
  73. local etat_rs = false
  74. local etat_rs2 = false
  75. local buzz = {false,false,false,false,false,false,false,false}
  76.  
  77. --initialisation de la redstone
  78. for i = 0, 15 do
  79. rs.setBundledOutput(cmd,i,255)
  80. rs.setBundledOutput(DTf,i,255)
  81. end
  82.  
  83.  
  84. --Fonctions
  85. local function setColor(bg,fg)
  86.   gpu.setBackground(bg)
  87.   gpu.setForeground(fg)
  88. end
  89.  
  90.  local function unit(qty)
  91.   if qty >= 1000000000 then
  92.     return string.format("%.02f MB",qty/10000000)
  93.   elseif qty >=1000000 then
  94.     return string.format("%.02f KB",qty/1000000)
  95.   elseif qty >=1000 then
  96.     return string.format("%.02f B ",qty/1000)
  97.   else
  98.     return string.format("%d mB",qty)
  99.   end
  100. end
  101.  
  102. local function unitrf(qty)
  103.   if qty >= 1000000000000000 or qty <= -1000000000000000 then
  104.     return string.format("%.03f PRF",qty/1000000000000000)
  105.   elseif qty >= 1000000000000 or qty <= -1000000000000 then
  106.     return string.format("%.03f TRF",qty/1000000000000)
  107.   elseif qty >=1000000000 or qty <= -1000000000 then
  108.     return string.format("%.03f GRF",qty/1000000000)
  109.   elseif qty >=1000000 or qty <= -1000000 then
  110.     return string.format("%.03f MRF",qty/1000000)
  111.   elseif qty >=1000 or qty <= -1000 then
  112.     return string.format("%.03f kRF",qty/1000)
  113.   else
  114.     return string.format("%.03f RF ",qty)
  115.   end
  116. end
  117.  
  118.  local function unitdeg(qty)
  119.   if qty >= 1000000000000000 then
  120.     return string.format("%.01fP°",qty/10000000000000)
  121.   elseif qty >= 1000000000000 then
  122.     return string.format("%.01fT°",qty/10000000000)
  123.   elseif qty >= 1000000000 then
  124.     return string.format("%.01fG°",qty/10000000)
  125.   elseif qty >=1000000 then
  126.     return string.format("%.01fM°",qty/1000000)
  127.   elseif qty >=1000 then
  128.     return string.format("%.01fK° ",qty/1000)
  129.   else
  130.     return string.format("%d°",qty)
  131.   end
  132. end
  133.  
  134. function loadbar(x,y,width,cur,text,bg,fg)
  135.   local raw = " " .. text ..string.rep(" ", width - unicode.len(text) - 2) .. " "
  136.   local oldbg = gpu.setBackground(bg)
  137.   local oldfg = gpu.setForeground(fg)
  138.   gpu.set(x,y,unicode.sub(raw,1,cur))
  139.   gpu.setBackground(oldbg)
  140.   gpu.setForeground(oldfg)
  141.   gpu.set(x+cur,y,unicode.sub(raw,cur+1,width))
  142. end
  143.  
  144. local function affenergie(x,y,length,tableau)
  145.   local amount = tableau[1] * 0.4
  146.   local capacity = tableau[2] * 0.4
  147.   local pct = amount / capacity
  148.   local color = cyan
  149.   local color2 = rouge
  150.   local cur = math.floor(pct * length)
  151.   local textfrac = string.format("%s / %s", unitrf(amount), unitrf(capacity))
  152.   local textpct = string.format("%.02f%%", pct*100)
  153.   local text1 = "        ENERGIE DANS LA BATTERIE MEKANISM "
  154.   local text2 = textfrac .. string.rep(" ", length - string.len(textfrac) - string.len(textpct) - 2) .. textpct
  155.   loadbar(x,y,length,cur,text1,color,color2)
  156.   loadbar(x,y+1,length,cur,text2,color,color2)
  157. end
  158.  
  159. local function afflaser(x,y,length,nlaser)
  160.   local amount = laser[nlaser].getEnergy() * 0.4
  161.   local capacity = laser[nlaser].getMaxEnergy() * 0.4
  162.   local pct = amount / capacity
  163.   local color = bleu
  164.   local color2 = jaune
  165.   local cur = math.floor(pct * length)
  166.   local textfrac = string.format("%s / %s", unitrf(amount), unitrf(capacity))
  167.   local textpct = string.format("%.02f%%", pct*100)
  168.   local texte_laser1
  169.   local texte_laser2
  170.   if amount == capacity then
  171.     texte_laser1 = "Chargé totalement"
  172.     table_bit[nlaser] = false
  173.   elseif table_bit[1] == false then
  174.     texte_laser1 = "En attente de charge"
  175.   elseif table_bit[1] == true then
  176.     if table_bit[nlaser] == false then
  177.       texte_laser1 = "En attente de charge"
  178.     else
  179.       texte_laser1 = "En  charge"
  180.     end
  181.   end
  182.   if amount < lancement then
  183.     texte_laser2 = " - Lancement impossible"
  184.   elseif amount >= lancement then
  185.     texte_laser2 = " - Lancement possible"
  186.   end
  187.   texte_palier = "│  Palier de lancement minimum : "..unitrf(lancement)
  188.   local text1 = " Charge du Laser Amplifier n°"..nlaser.." - "..texte_laser1..texte_laser2
  189.   local text2 = textfrac .. string.rep(" ", length - string.len(textfrac) - string.len(textpct) - 2) .. textpct
  190.   loadbar(x,y,length,cur,text1,color,color2)
  191.   loadbar(x,y+1,length,cur,text2,color,color2)
  192. end
  193.  
  194. local function lvl_dtfuel(x,y,length,ntank)
  195.   local amount = tank[ntank][1].getFluidInTank(0)[1].amount
  196.   local capacity = tank[ntank][1].getFluidInTank(0)[1].capacity
  197.   local pct = amount / capacity
  198.   local cur = math.floor(pct * length)
  199.   local bg = tank[ntank].color
  200.   local fg = blanc - bg
  201.   local text = ntank.." : "..string.format("%06.02f%%",pct)
  202.   loadbar(x,y,length,cur,text,bg,fg)
  203.   loadbar(x,y+1,length,cur,text,bg,fg)
  204. end
  205.  
  206. local function barre_verticale(x,y,hauteur,largeur,entete,ntank,color1,color2)
  207.   local k = 0
  208.   local amount = tank[ntank][1].getFluidInTank(0)[1].amount
  209.   local capacity = tank[ntank][1].getFluidInTank(0)[1].capacity
  210.   local cur = math.floor((amount / capacity) * hauteur)
  211.   local dir = string.rep(" ",largeur)
  212.   for k = 1, hauteur do
  213.     local vy = y + hauteur - k
  214.     if k <= cur then
  215.       setColor(color1,color2)
  216.     elseif k > cur then
  217.       setColor(noir,blanc)  
  218.     end
  219.       gpu.set(x,vy,dir)
  220.     if k == 1 then
  221.       gpu.set(x,vy,dir)
  222.       gpu.set(x,vy,"  Max "..unit(capacity))
  223.     elseif k == 3 then
  224.       gpu.set(x,vy,dir)
  225.       gpu.set(x,vy,"  Cur "..unit(amount))
  226.     elseif k == 4 then
  227.       gpu.set(x,vy,dir)
  228.       gpu.set(x,vy,string.format("  Cur %06.02f%%  ",(amount/capacity)*100))
  229.     elseif k == hauteur then
  230.       gpu.set(x,vy,entete)
  231.     end
  232.     setColor(noir,blanc)
  233.   end
  234. end
  235.  
  236. local function bouton(x,y,etat,text,color,color2)
  237.   if etat == true then
  238.     setColor(color,color2)
  239.     gpu.set(x,y," "..text.." ")
  240.     setColor(noir,blanc)
  241.   elseif etat == false then
  242.     setColor(color2,color)
  243.     gpu.set(x,y," "..text.." ")
  244.     setColor(noir,blanc)
  245.   end
  246. end
  247.  
  248. local function bouton_rotary(x,y,netat)
  249.   local text
  250.     if table_rotary[netat].bit == true then
  251.       text = "ON "
  252.       bouton(x,y,table_rotary[netat].bit,text,vert,noir)
  253.       setColor(bleu,jaune)
  254.       gpu.set(2+netat*3,8,netat)
  255.       setColor(noir,blanc)
  256.     elseif table_rotary[netat].bit == false then
  257.       text = "OFF"
  258.       bouton(x,y,table_rotary[netat].bit,text,rouge,noir)
  259.       setColor(rouge,cyan)
  260.       gpu.set(2+netat*2,8,netat)
  261.       setColor(noir,blanc)
  262.     end
  263. end
  264.  
  265. local function boutonx2(x,y,x2,y2,nbit,text1,text2,color1,color2,color3,color4,espace)
  266.   if x2 > x-1 and x2 < x+string.len(text1)+2 and y2 == y then
  267.     table_bit[nbit] = true
  268.   elseif x2 > x+string.len(text1)+2 and x2 < x+string.len(text1)+string.len(text2)+5 and y2 == y then
  269.     table_bit[nbit] = false
  270.   end
  271.   bouton(x,y,table_bit[nbit],text1,color1,color2)
  272.   bouton(x+string.len(text1)+2+espace,y,not(table_bit[nbit]),text2,color3,color4)
  273. end
  274.  
  275. local function bouton_vanne(x,y,x2,y2,nbit)
  276.   if x2 > x-1 and x2 < x+5 and y > y-1 and y < y+4 then
  277.     if table_bit[nbit] == false then
  278.       table_bit[nbit] = true
  279.     elseif table_bit[nbit] == true then
  280.       table_bit[nbit] = false
  281.     end
  282.   end
  283.   if table_bit[nbit] == true then
  284.     bouton(x,y,table_bit[nbit],"ON ",vert,noir)
  285.     setColor(noir,vert)
  286.     gpu.set(x+2,y+1," ")
  287.     gpu.set(x,y+2,"═════")
  288.     gpu.set(x+2,y+3," ")
  289.   elseif table_bit[nbit] == false then
  290.     bouton(x,y,table_bit[nbit],"OFF",noir,rouge)
  291.     setColor(noir,rouge)
  292.     gpu.set(x+2,y+1,"║")
  293.     gpu.set(x,y+2,"  ║  ")
  294.     gpu.set(x+2,y+3,"║")
  295.   end
  296.   setColor(noir,blanc)
  297. end
  298.  
  299. local function afflasers(x,y,length)
  300.   afflaser(x,y,length,1)
  301.   afflaser(x,y+3,length,2)
  302. end
  303.  
  304. local function conversion_binaire_nombre(etat)
  305.   if etat == false then
  306.     return 255
  307.   elseif etat == true then
  308.     return 0
  309.   end
  310. end
  311.  
  312. local function conversion_nombre_binaire(etat)
  313.   if etat == 0 then
  314.     return true
  315.   elseif etat > 0 then
  316.     return false
  317.   end
  318. end
  319.  
  320. local function ctrl_fusion(x,y)
  321.   local width_case = 22
  322.   local width_plasma = 20
  323.   local width_energy = 22
  324.   local color1_case = 0xff5b43
  325.   local color2_case = blanc - color1_case
  326.   local color1_plasma = 0xfdffbf
  327.   local color2_plasma = blanc - color1_plasma
  328.   local color1_energy = 0x5fff3b
  329.   local color2_energy = blanc - color1_energy
  330.  
  331.   local case_heat = fusion.getCaseHeat()
  332.   local max_case_heat
  333.   local cur_case
  334.   if table_bit[4] == true then
  335.     max_case_heat = 5000
  336.   elseif table_bit[4] == false then
  337.     max_case_heat = fusion.getMaxCaseHeat()
  338.   end
  339.   if max_case_heat == 0 then
  340.     cur_case = math.floor(case_heat / 5000 * width_case)
  341.   else
  342.     cur_case = math.floor(case_heat / max_case_heat * width_case)
  343.   end
  344.   local text1_case = "  Case heat   "
  345.   local text2_case = unitdeg(case_heat).." / "..unitdeg(max_case_heat)
  346.   loadbar(x,y-2,width_case,cur_case,text1_case,color1_case,color2_case)
  347.   loadbar(x,y-1,width_case,cur_case,text2_case,color1_case,color2_case)
  348.  
  349.   local plasma_heat = fusion.getPlasmaHeat()
  350.   local max_plasma_heat
  351.   local cur_plasma
  352.   if table_bit[4] == true then
  353.     max_plasma_heat = 7500
  354.   elseif table_bit[4] == false then
  355.     max_plasma_heat = fusion.getMaxPlasmaHeat()
  356.   end
  357.   if max_plasma_heat == 0 then
  358.     cur_plasma = math.floor(plasma_heat / 7500 * width_plasma)
  359.   else
  360.     cur_plasma = math.floor(plasma_heat / max_plasma_heat * width_plasma)
  361.   end
  362.   local text1_plasma = "  Temp. plasma  "
  363.   local text2_plasma = unitdeg(plasma_heat).." / "..unitdeg(max_plasma_heat)
  364.   loadbar(x+1,y-4,width_plasma,cur_plasma,text1_plasma,color1_plasma,color2_plasma)
  365.   loadbar(x+1,y-3,width_plasma,cur_plasma,text2_plasma,color1_plasma,color2_plasma)
  366.   gpu.set(x+1,y-4,"/")
  367.   gpu.set(x+20,y-4,[[\]])
  368.  
  369.   local energy = fusion.getEnergy() * 0.4
  370.   local max_energy = fusion.getMaxEnergy() * 0.4
  371.   local cur_energy = math.floor(energy / max_energy * width_energy)
  372.   local text1_energy = "   Energie stockée    "
  373.   local text2_energy = unitrf(energy).." / "..string.format("%d GRF",max_energy/1000000000)
  374.   loadbar(x,y+1,width_energy,cur_energy,text1_energy,color1_energy,color2_energy)
  375.   loadbar(x,y+2,width_energy,cur_energy,text2_energy,color1_energy,color2_energy)
  376.  
  377.   if fusion.canIgnite() == true then
  378.     setColor(noir,vert)
  379.     gpu.set(x,y,"    Réacteur prêt     ")
  380.   elseif fusion.canIgnite() == false then
  381.     setColor(noir,rouge)
  382.     gpu.set(x,y," Réacteur en attente  ")
  383.  
  384.   end
  385.   rs.setBundledOutput(cmd,9,conversion_binaire_nombre(fusion.canIgnite()))
  386. end
  387.  
  388. local function affrotaryx12(x,y)
  389. print("a")
  390.   if etat_rs ~= etat_rs2 then
  391. print("b")
  392.     local i
  393.     gpu.set(30,8,tostring(test))
  394.     for i = 0, 11 do
  395.       if i <= 5 then
  396.         bouton_rotary(x-8*(i),15,i)
  397.       elseif i > 5 and i <= 11 then
  398.         bouton_rotary(x-8*(i-6),39,i)
  399.       end
  400.     end
  401. print("c")
  402.     etat_rs2 = etat_rs
  403. print("d")
  404.   end
  405. print("y")
  406. end
  407.  
  408. local function aff_pourcent()
  409.   setColor(bleu,blanc)
  410.   local alim_pct = alim_fusion_dtfuel_value / 24
  411.   gpu.set(26,22,string.format("% 6.02f%%", alim_pct*100))
  412.   setColor(noir,blanc)
  413.   if table_bit[4] == false then
  414.     setColor(orange,noir)
  415.     gpu.set(48,31,string.format("% 6d", fusion.getInjectionRate()))
  416.     setColor(noir,blanc)
  417.   elseif table_bit[4] == true then
  418.     gpu.set(48,31,"-------")
  419.     fusion.setInjectionRate(0)
  420.   end
  421. end
  422.  
  423. local function cmd_rotary()
  424. local i
  425.   for i = 0, 24 do
  426.     if i < alim_fusion_dtfuel_value then
  427.       if i < 12 then
  428.         rs.setBundledOutput(DTg,i,0)
  429.         table_rotary[i].bit = true
  430.       elseif i >= 12 then
  431.         rs.setBundledOutput(DTd,i-12,0)
  432.         table_rotary[i+12].bit = true
  433.       end
  434.     elseif i >= alim_fusion_dtfuel_value then
  435.       if i < 12 then
  436.         rs.setBundledOutput(DTg,i,255)
  437.         table_rotary[i].bit = false
  438.       elseif i >= 12 then
  439.         rs.setBundledOutput(DTd,i-12,255)
  440.         table_rotary[i+12].bit = false
  441.       end
  442.     end
  443.   end
  444. end
  445.  
  446. local function start_auto()
  447.   if table_bit[14] == true and etape_demarrage == 0 and fusion.isIgnited() == false then
  448.     buzzer(0,255)
  449.     decompte = decompte - 1
  450.     if decompte == 0 then
  451.       table_bit[1] = true
  452.       etape_demarrage = 1
  453.       buzzer(0,255)
  454.       decompte = decompte_max
  455.     end
  456.   elseif table_bit[14] == false or fusion.isIgnited() == true then
  457.     etape_demarrage = 0
  458.     decompte = decompte_max
  459.   end
  460.  
  461.   if etape_demarrage == 0 then
  462.     if rs.getBundledOutput(cmd,8) ~= 0 then
  463.       --rs.setBundledOutput(cmd,8,0) = 0  
  464.     end
  465.   elseif etape_demarrage == 1 then
  466.     table_bit[1] = true
  467.     if laser[1].getEnergy() * 0.4 < lancement then
  468.       table_bit[2] = true
  469.     else
  470.       table_bit[2]= false
  471.     end
  472.     if laser[2].getEnergy() * 0.4 < lancement then
  473.       table_bit[3] = true
  474.     else
  475.       table_bit[3]= false
  476.     end
  477.     if laser[1].getEnergy() * 0.4 < lancement and laser[2].getEnergy() * 0.4 < lancement then
  478.       etape_demarrage = 2
  479.     end
  480.   elseif etape_demarrage == 2 then
  481.     if table_bit[4] == false then
  482.       ratio_fusion = 2
  483.     elseif table_bit[4] == true then
  484.       alim_fusion_dtfuel_value = 1
  485.     end
  486.     etape_demarrage = 3
  487.  
  488.   elseif etape_demarrage == 3 then
  489.     buzzer(1,255)
  490.     decompte = decompte - 1
  491.     if decompte == 0 then
  492.       rs.setBundledOutput(cmd,8,255)
  493.       etape_demarrage = 0
  494.       buzzer(1,255)
  495.       decompte = decompte_max
  496.     end
  497.   end
  498. end
  499.  
  500. local function buzzer(nbuzzer,value)
  501.   rs.setBundledOutput(alm,nbuzzer,value)  
  502. end
  503.  
  504. local function binaire_redstone()
  505.   rs.setBundledOutput(cmd,0,conversion_binaire_nombre(table_bit[2]))  -- laser gauche
  506.   --rs.setBundledOutput(cmd,1,conversion_binaire_nombre()  --
  507.   rs.setBundledOutput(cmd,2,conversion_binaire_nombre(table_bit[6]))  -- alim fusion en deutérium
  508.   rs.setBundledOutput(cmd,3,conversion_binaire_nombre(table_bit[5]))  -- alim fusion en tritium
  509.   rs.setBundledOutput(cmd,4,conversion_binaire_nombre(table_bit[4]))  -- alim fusion dt-fuel ou deut-trit
  510.   rs.setBundledOutput(cmd,5,conversion_binaire_nombre(not(table_bit[4])))  -- alim fusion dt-fuel ou deut-trit
  511.   rs.setBundledOutput(cmd,6,conversion_binaire_nombre(table_bit[7]))  -- alim cuve gauche dt-fuel
  512.   --rs.setBundledOutput(cmd,7,conversion_binaire_nombre()  --
  513.   rs.setBundledOutput(cmd,11,conversion_binaire_nombre(table_bit[11]))  -- alim machinerie dt-fuel en tritium
  514.   --rs.setBundledOutput(cmd,12,conversion_binaire_nombre())  --
  515.   --rs.setBundledOutput(cmd,13,conversion_binaire_nombre())  --
  516.   rs.setBundledOutput(cmd,14,conversion_binaire_nombre(table_bit[12]))  -- alim machinerie dt-fuel en deutérium
  517.   --rs.setBundledOutput(cmd,15,conversion_binaire_nombre())  --
  518. end
  519.  
  520. local function affboutons(x,y)
  521.   boutonx2(62,43,x,y,1,"ON","OFF",vert,noir,rouge,noir,1)
  522.   boutonx2(24,32,x,y,2,"ON","OFF",vert,noir,rouge,noir,2)
  523.   boutonx2(67,32,x,y,3,"ON","OFF",vert,noir,rouge,noir,2)
  524.   boutonx2(20,43,x,y,4,"D-T Fuel","Deutérium-Tritium",violet,noir,jaune,noir,1)
  525.   boutonx2(87,43,x,y,10,"ON","OFF",vert,noir,rouge,noir,2)
  526.   boutonx2(4,9,x,y,14,"ON","OFF",vert,noir,rouge,noir,2)
  527.   bouton_vanne(29,24,x,y,5)
  528.   bouton_vanne(68,24,x,y,6)
  529.   aff_pourcent()
  530.   binaire_redstone()
  531. end
  532.  
  533. --Matrices
  534. "z")
  535. affboutons(2,1)
  536.  
  537. local function onTouch(event,address,x,y,clic,pseudo)
  538.   local tclic
  539.   if clic == 0  then
  540.     tclic = "Clic gauche"
  541.   elseif clic == 1 then
  542.     tclic = "Clic droit"
  543.   else
  544.     tclic = "Clic inconnu"
  545.   end
  546.   gpu.set(2,2,"                                                                                                  ")
  547.   gpu.set(5,2," "..tclic.." de la part de "..pseudo.." / X : "..string.format("% 3s",x).." / Y : "..string.format("% 3s",y))
  548.   if x~=1 and y~=1 then
  549.     if y==22 then
  550.       if x>22 and x<26 then
  551.         alim_fusion_dtfuel_value = alim_fusion_dtfuel_value + 1
  552.         if alim_fusion_dtfuel_value > 24 then
  553.           alim_fusion_dtfuel_value = 24
  554.         end
  555.       elseif x>32 and x<36 then
  556.         alim_fusion_dtfuel_value = alim_fusion_dtfuel_value - 1
  557.         if alim_fusion_dtfuel_value < 0 then
  558.           alim_fusion_dtfuel_value = 0
  559.         end
  560.       end
  561.     elseif y==34 then
  562.       if x>13 and x<20 then
  563.         ratio_fusion = ratio_fusion - 10000
  564.         if ratio_fusion < 0 then
  565.           ratio_fusion = 0
  566.         end
  567.       elseif x>20 and x<26 then
  568.         ratio_fusion = ratio_fusion - 1000
  569.         if ratio_fusion < 0 then
  570.           ratio_fusion = 0
  571.         end
  572.       elseif x>26 and x<31 then
  573.         ratio_fusion = ratio_fusion - 100
  574.         if ratio_fusion < 0 then
  575.           ratio_fusion = 0
  576.         end
  577.       elseif x>31 and x<35 then
  578.         ratio_fusion = ratio_fusion - 10
  579.         if ratio_fusion < 0 then
  580.           ratio_fusion = 0
  581.         end
  582.       elseif x>35 and x<38 then
  583.         ratio_fusion = ratio_fusion - 2
  584.         if ratio_fusion < 0 then
  585.           ratio_fusion = 0
  586.         end
  587.       elseif x>63 and x<66 then
  588.         ratio_fusion = ratio_fusion + 2
  589.         if ratio_fusion > 100000 then
  590.           ratio_fusion = 100000
  591.         end
  592.       elseif x>66 and x<70 then
  593.         ratio_fusion = ratio_fusion + 10
  594.         if ratio_fusion > 100000 then
  595.           ratio_fusion = 100000
  596.         end
  597.       elseif x>70 and x<75 then
  598.         ratio_fusion = ratio_fusion + 100
  599.         if ratio_fusion > 100000 then
  600.           ratio_fusion = 100000
  601.         end
  602.       elseif x>75 and x<81 then
  603.         ratio_fusion = ratio_fusion + 1000
  604.         if ratio_fusion > 100000 then
  605.           ratio_fusion = 100000
  606.         end
  607.       elseif x>81 and x<88 then
  608.         ratio_fusion = ratio_fusion + 10000
  609.         if ratio_fusion > 100000 then
  610.           ratio_fusion = 100000
  611.         end
  612.       end
  613.       fusion.setInjectionRate(ratio_fusion)
  614.     end
  615.     affboutons(x,y)
  616.   elseif x==1 and y==1 then
  617.     computer.pushSignal("quit")
  618.     term.setCursor(1,1)
  619.     return false
  620.   end
  621. end
  622.  
  623. local function onTimer(_,timer)
  624.   lvl_dtfuel(65,21,15,3)
  625.   barre_verticale(4,22,11,15,"    TRITIUM    ",3,bleu,jaune)
  626.   barre_verticale(83,22,11,15,"   DEUTERIUM   ",3,rouge,vert)
  627.   afflasers(2,45,98)
  628.   affrotaryx12(44,15)
  629.   ctrl_fusion(40,26)
  630.  
  631.   return true
  632. end
  633.  
  634. event.listen("touch",onTouch)
  635. local timer = event.timer(.1,onTimer,math.huge)
  636. event.listen("redstone_changed", onRedstone)
  637. event.pull("quit")
  638. event.cancel(timer)
  639. event.ignore("touch",onTouch)
  640. event.ignore("redstone_changed", onRedstone)
  641.  
  642. rs.setBundledOutput(cmd,0,conversion_binaire_nombre(false))  -- laser gauche
  643. rs.setBundledOutput(cmd,1,conversion_binaire_nombre(false))  -- laser droite
  644. rs.setBundledOutput(cmd,2,conversion_binaire_nombre(false))  -- alim fusion en deutérium
  645. rs.setBundledOutput(cmd,3,conversion_binaire_nombre(false))  -- alim fusion en tritium
  646. rs.setBundledOutput(cmd,4,conversion_binaire_nombre(false))  -- alim fusion dt-fuel ou deut-trit
  647. rs.setBundledOutput(cmd,5,conversion_binaire_nombre(true))  -- alim fusion dt-fuel ou deut-trit
  648. rs.setBundledOutput(cmd,6,conversion_binaire_nombre(false))  -- alim cuve gauche dt-fuel
  649. rs.setBundledOutput(cmd,7,conversion_binaire_nombre(false))  -- alim cuve droite dt-fuel
  650. rs.setBundledOutput(cmd,8,conversion_binaire_nombre(true))  -- activation laser amplifier - lancement fusion
  651.   --rs.setBundledOutput(cmd,9,)  -- laser_pret activé dans fonction ctrl_fusion
  652. rs.setBundledOutput(cmd,11,conversion_binaire_nombre(false))  -- alim machinerie dt-fuel en tritium
  653. rs.setBundledOutput(cmd,14,conversion_binaire_nombre(false))  -- alim machinerie dt-fuel en deutérium
  654.  
  655. setColor(noir,blanc)
  656. gpu.setResolution(160,45)
  657. gpu.fill(1,1,160,50," ")
  658.  
  659. --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