sshikamaru

Fusion aero dimension

Aug 7th, 2019
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.88 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 laser = 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 ratio_dtf = false
  45. local alim_fusion_dtfuel_value = 0
  46. local alim_fusion_dtfuel_value_attente = 0
  47. local etape_demarrage = 0
  48. local decompte_max = 10
  49. local decompte = decompte_max
  50. local table_bit = {
  51.     false, -- 1 charge_laser
  52.     false, -- 2 charge_laser1
  53.     false, -- 3
  54.     false, -- 4 alim_fusion
  55.     false, -- 5 alim_fusion_tritium
  56.     false, -- 6 alim_fusion_deuterium
  57.     false, -- 7 alim_cuve_dtfuel
  58.     false, -- 8
  59.     false, -- 9 activation_laser_amplifier
  60.     false, -- 10 alarmes activées/désactivées
  61.     false, -- 11 alim_dtfuel_tritium
  62.     false, -- 12 alim_dtfuel_deuterium
  63.     false, -- 13 laser chargés
  64.     false, -- 14 démarrage auto
  65.     false, -- 15
  66.     false --
  67. }
  68. local table_rotary = {}
  69. local i = 0
  70. for i = 0, 11 do
  71.     local text = "Rotary n°"..tostring(i+1)
  72.     local v1 = false
  73.     table_rotary[i] = {label=text,bit=v1}
  74. end
  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)
  160.     local amount = laser.getEnergy() * 0.4
  161.     local capacity = laser.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[2] = 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[2] == 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 - "..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(noir,blanc)
  254.     elseif table_rotary[netat].bit == false then
  255.         text = "OFF"
  256.         bouton(x,y,table_rotary[netat].bit,text,rouge,noir)
  257.         setColor(noir,blanc)
  258.     end
  259. end
  260.  
  261. local function boutonx2(x,y,x2,y2,nbit,text1,text2,color1,color2,color3,color4,espace)
  262.     if x2 > x-1 and x2 < x+string.len(text1)+2 and y2 == y then
  263.         table_bit[nbit] = true
  264.     elseif x2 > x+string.len(text1)+2 and x2 < x+string.len(text1)+string.len(text2)+5 and y2 == y then
  265.         table_bit[nbit] = false
  266.     end
  267.     bouton(x,y,table_bit[nbit],text1,color1,color2)
  268.     bouton(x+string.len(text1)+2+espace,y,not(table_bit[nbit]),text2,color3,color4)
  269. end
  270.  
  271. local function bouton_vanne(x,y,nbit)
  272.     if table_bit[nbit] == true then
  273.         bouton(x,y,table_bit[nbit],"ON ",vert,noir)
  274.         setColor(noir,vert)
  275.         gpu.set(x+2,y+1," ")
  276.         gpu.set(x,y+2,"═════")
  277.         gpu.set(x+2,y+3," ")
  278.     elseif table_bit[nbit] == false then
  279.         bouton(x,y,table_bit[nbit],"OFF",noir,rouge)
  280.         setColor(noir,rouge)
  281.         gpu.set(x+2,y+1,"║")
  282.         gpu.set(x,y+2,"  ║  ")
  283.         gpu.set(x+2,y+3,"║")
  284.     end
  285.     setColor(noir,blanc)
  286. end
  287.  
  288. local function conversion_binaire_nombre(etat)
  289.     if etat == false then
  290.         return 255
  291.     elseif etat == true then
  292.         return 0
  293.     end
  294. end
  295.  
  296. local function conversion_nombre_binaire(etat)
  297.     if etat == 0 then
  298.         return true
  299.     elseif etat > 0 then
  300.         return false
  301.     end
  302. end
  303.  
  304. local function ctrl_fusion(x,y)
  305.     local width_case = 22
  306.     local width_plasma = 20
  307.     local width_energy = 22
  308.     local color1_case = 0xff5b43
  309.     local color2_case = blanc - color1_case
  310.     local color1_plasma = 0xfdffbf
  311.     local color2_plasma = blanc - color1_plasma
  312.     local color1_energy = 0x5fff3b
  313.     local color2_energy = blanc - color1_energy
  314.     local case_heat = fusion.getCaseHeat()
  315.     local max_case_heat
  316.     local cur_case
  317.     if table_bit[4] == true then
  318.         max_case_heat = 5000
  319.     elseif table_bit[4] == false then
  320.         max_case_heat = fusion.getMaxCaseHeat()
  321.     end
  322.     if max_case_heat == 0 then
  323.         cur_case = math.floor(case_heat / 5000 * width_case)
  324.     else
  325.         cur_case = math.floor(case_heat / max_case_heat * width_case)
  326.     end
  327.     local text1_case = "  Case heat   "
  328.     local text2_case = unitdeg(case_heat).." / "..unitdeg(max_case_heat)
  329.     loadbar(x,y-2,width_case,cur_case,text1_case,color1_case,color2_case)
  330.     loadbar(x,y-1,width_case,cur_case,text2_case,color1_case,color2_case)
  331.  
  332.     local plasma_heat = fusion.getPlasmaHeat()
  333.     local max_plasma_heat
  334.     local cur_plasma
  335.     if table_bit[4] == true then
  336.         max_plasma_heat = 7500
  337.     elseif table_bit[4] == false then
  338.         max_plasma_heat = fusion.getMaxPlasmaHeat()
  339.     end
  340.     if max_plasma_heat == 0 then
  341.         cur_plasma = math.floor(plasma_heat / 7500 * width_plasma)
  342.     else
  343.         cur_plasma = math.floor(plasma_heat / max_plasma_heat * width_plasma)
  344.     end
  345.     local text1_plasma = "  Temp. plasma  "
  346.     local text2_plasma = unitdeg(plasma_heat).." / "..unitdeg(max_plasma_heat)
  347.     loadbar(x+1,y-4,width_plasma,cur_plasma,text1_plasma,color1_plasma,color2_plasma)
  348.     loadbar(x+1,y-3,width_plasma,cur_plasma,text2_plasma,color1_plasma,color2_plasma)
  349.     gpu.set(x+1,y-4,"/")
  350.     gpu.set(x+20,y-4,[[\]])
  351.  
  352.     local energy = fusion.getEnergy() * 0.4
  353.     local max_energy = fusion.getMaxEnergy() * 0.4
  354.     local cur_energy = math.floor(energy / max_energy * width_energy)
  355.     local text1_energy = "   Energie stockée    "
  356.     local text2_energy = unitrf(energy).." / "..string.format("%d GRF",max_energy/1000000000)
  357.     loadbar(x,y+1,width_energy,cur_energy,text1_energy,color1_energy,color2_energy)
  358.     loadbar(x,y+2,width_energy,cur_energy,text2_energy,color1_energy,color2_energy)
  359.  
  360.     if fusion.canIgnite() == true then
  361.         setColor(noir,vert)
  362.        gpu.set(x,y,"    Réacteur prêt     ")
  363.     elseif fusion.canIgnite() == false then
  364.         setColor(noir,rouge)
  365.         gpu.set(x,y," Réacteur en attente  ")
  366.  
  367.     end
  368.     rs.setBundledOutput(cmd,9,conversion_binaire_nombre(fusion.canIgnite()))
  369. end
  370.  
  371. local function aff_pourcent()
  372.     setColor(bleu,blanc)
  373.     local alim_pct = alim_fusion_dtfuel_value / 12
  374.     gpu.set(26,21,string.format("% 6.02f%%", alim_pct*100))
  375.     setColor(noir,blanc)
  376.     if table_bit[4] == false then
  377.         setColor(orange,noir)
  378.         gpu.set(48,31,string.format("% 6d", fusion.getInjectionRate()))
  379.         setColor(noir,blanc)
  380.     elseif table_bit[4] == true then
  381.         gpu.set(48,31,"-------")
  382.         fusion.setInjectionRate(0)
  383.     end
  384. end
  385.  
  386. local function cmd_rotary()
  387.     local i
  388.     for i = 0, 11 do
  389.         if i < alim_fusion_dtfuel_value then
  390.             rs.setBundledOutput(DTf,i,0)
  391.             table_rotary[i].bit = true
  392.         elseif i >= alim_fusion_dtfuel_value then
  393.             rs.setBundledOutput(DTf,i,255)
  394.             table_rotary[i].bit = false
  395.         end
  396.         if i <= 5 then
  397.             bouton_rotary(x-8*i,15,i)
  398.          elseif i > 5 and i <= 11 then
  399.             bouton_rotary(x+9+8*(i-6),15,i)
  400.         end
  401.     end
  402. end
  403.  
  404. local function start_auto()
  405.     if table_bit[14] == true and etape_demarrage == 0 and fusion.isIgnited() == false then
  406.         buzzer(0,255)
  407.         decompte = decompte - 1
  408.         if decompte == 0 then
  409.             table_bit[1] = true
  410.             etape_demarrage = 1
  411.             buzzer(0,255)
  412.             decompte = decompte_max
  413.         end
  414.     elseif table_bit[14] == false or fusion.isIgnited() == true then
  415.         etape_demarrage = 0
  416.         decompte = decompte_max
  417.     end
  418.  
  419.     if etape_demarrage == 0 then
  420.         if rs.getBundledOutput(cmd,8) ~= 0 then
  421.             rs.setBundledOutput(cmd,8,0)  
  422.         end
  423.     elseif etape_demarrage == 1 then
  424.         table_bit[1] = true
  425.         if laser[1].getEnergy() * 0.4 < lancement then
  426.             table_bit[2] = true
  427.         else
  428.             table_bit[2]= false
  429.         end
  430.         if laser[2].getEnergy() * 0.4 < lancement then
  431.             table_bit[3] = true
  432.         else
  433.             table_bit[3]= false
  434.         end
  435.         if laser[1].getEnergy() * 0.4 < lancement and laser[2].getEnergy() * 0.4 < lancement then
  436.             etape_demarrage = 2
  437.         end
  438.     elseif etape_demarrage == 2 then
  439.         if table_bit[4] == false then
  440.             ratio_fusion = 2
  441.         elseif table_bit[4] == true then
  442.             alim_fusion_dtfuel_value = 1
  443.         end
  444.         etape_demarrage = 3
  445.  
  446.     elseif etape_demarrage == 3 then
  447.         buzzer(1,255)
  448.         decompte = decompte - 1
  449.         if decompte == 0 then
  450.             rs.setBundledOutput(cmd,8,255)
  451.             etape_demarrage = 0
  452.             buzzer(1,255)
  453.             decompte = decompte_max
  454.         end
  455.     end
  456. end
  457.  
  458. local function buzzer(nbuzzer,value)
  459.     rs.setBundledOutput(alm,nbuzzer,value)  
  460. end
  461.  
  462. local function binaire_redstone()
  463.     rs.setBundledOutput(cmd,0,conversion_binaire_nombre(table_bit[2]))  -- laser gauche
  464.     --rs.setBundledOutput(cmd,1,conversion_binaire_nombre()  --
  465.     rs.setBundledOutput(cmd,2,conversion_binaire_nombre(table_bit[6]))  -- alim fusion en deutérium
  466.     rs.setBundledOutput(cmd,3,conversion_binaire_nombre(table_bit[5]))  -- alim fusion en tritium
  467.     rs.setBundledOutput(cmd,4,conversion_binaire_nombre(table_bit[4]))  -- alim fusion dt-fuel ou deut-trit
  468.     rs.setBundledOutput(cmd,5,conversion_binaire_nombre(not(table_bit[4])))  -- alim fusion dt-fuel ou deut-trit
  469.     rs.setBundledOutput(cmd,6,conversion_binaire_nombre(table_bit[7]))  -- alim cuve gauche dt-fuel
  470.     --rs.setBundledOutput(cmd,7,conversion_binaire_nombre()  --
  471.     rs.setBundledOutput(cmd,11,conversion_binaire_nombre(table_bit[11]))  -- alim machinerie dt-fuel en tritium
  472.     --rs.setBundledOutput(cmd,12,conversion_binaire_nombre())  --
  473.     --rs.setBundledOutput(cmd,13,conversion_binaire_nombre())  --
  474.     rs.setBundledOutput(cmd,14,conversion_binaire_nombre(table_bit[12]))  -- alim machinerie dt-fuel en deutérium
  475.     --rs.setBundledOutput(cmd,15,conversion_binaire_nombre())  --
  476. end
  477.  
  478. local function affboutons(x,y)
  479.     boutonx2(62,43,x,y,1,"ON","OFF",vert,noir,rouge,noir,1)
  480.     boutonx2(24,31,x,y,2,"ON","OFF",vert,noir,rouge,noir,2)
  481.     boutonx2(20,43,x,y,4,"D-T Fuel","Deutérium-Tritium",violet,noir,jaune,noir,1)
  482.     boutonx2(87,43,x,y,10,"ON","OFF",vert,noir,rouge,noir,2)
  483.     boutonx2(4,9,x,y,14,"ON","OFF",vert,noir,rouge,noir,2)
  484.     binaire_redstone()
  485. end
  486.  
  487. local function init()
  488.     affboutons(2,1)
  489.     cmd_rotary()
  490.     bouton_vanne(29,24,5)
  491.     bouton_vanne(68,24,6)
  492.     aff_pourcent()
  493. end
  494.  
  495. --Matrices
  496. "Clic gauche"
  497.     elseif clic == 1 then
  498.         tclic = "Clic droit"
  499.     else
  500.         tclic = "Clic inconnu"
  501.     end
  502.     gpu.set(2,2,"                                                                                                  ")
  503.     gpu.set(5,2," "..tclic.." de la part de "..pseudo.." / X : "..string.format("% 3s",x).." / Y : "..string.format("% 3s",y))
  504.     if x~=1 and y~=1 then
  505.         if y==21 and x>22 and x<36 then
  506.             if ratio_dtf == false then
  507.                 alim_fusion_dtfuel_value_attente = alim_fusion_dtfuel_value
  508.             end
  509.             ratio_dtf = true
  510.             gpu.set(22,22,"  ok   annulé  ")
  511.             if x>22 and x<26 then  -- rotary +1
  512.                 alim_fusion_dtfuel_value = alim_fusion_dtfuel_value + 1
  513.                 if alim_fusion_dtfuel_value > 12 then
  514.                     alim_fusion_dtfuel_value = 12
  515.                 end
  516.             elseif x>32 and x<36 then  -- rotary -1
  517.               alim_fusion_dtfuel_value = alim_fusion_dtfuel_value - 1
  518.               if alim_fusion_dtfuel_value < 0 then
  519.                     alim_fusion_dtfuel_value = 0
  520.                 end
  521.             end
  522.             aff_pourcent()
  523.         elseif y==22 and x>22 and x<27 then  --ok
  524.             if ratio_dtf == true then
  525.                 cmd_rotary()
  526.                 ratio_dtf = false
  527.                 gpu.set(22,22,"               ")
  528.             end
  529.             aff_pourcent()
  530.         elseif y==22 and x>28 and x<35 then  --annulé
  531.             if ratio_dtf == true then
  532.                 alim_fusion_dtfuel_value = alim_fusion_dtfuel_value_attente
  533.                 ratio_dtf = false
  534.                 gpu.set(22,22,"               ")
  535.             end
  536.             aff_pourcent()
  537.         elseif y>24 and y<28 and x>28 and x<34 then
  538.             table_bit[5] = not table_bit[5]
  539.             bouton_vanne(29,24,5)
  540.         elseif y>24 and y<28 and x>67 and x<73 then
  541.             table_bit[6] = not table_bit[6]
  542.             bouton_vanne(68,24,6)
  543.         elseif y==34 then
  544.             if x>13 and x<20 then
  545.                 ratio_fusion = ratio_fusion - 10000
  546.             elseif x>20 and x<26 then
  547.                 ratio_fusion = ratio_fusion - 1000
  548.             elseif x>26 and x<31 then
  549.                 ratio_fusion = ratio_fusion - 100
  550.             elseif x>31 and x<35 then
  551.                 ratio_fusion = ratio_fusion - 10
  552.             elseif x>35 and x<38 then
  553.                 ratio_fusion = ratio_fusion - 2
  554.             elseif x>63 and x<66 then
  555.                 ratio_fusion = ratio_fusion + 2
  556.             elseif x>66 and x<70 then
  557.                 ratio_fusion = ratio_fusion + 10
  558.             elseif x>70 and x<75 then
  559.                 ratio_fusion = ratio_fusion + 100
  560.             elseif x>75 and x<81 then
  561.                 ratio_fusion = ratio_fusion + 1000
  562.             elseif x>81 and x<88 then
  563.                 ratio_fusion = ratio_fusion + 10000
  564.             end
  565.             if ratio_fusion < 0 then
  566.                 ratio_fusion = 0
  567.             end
  568.             if ratio_fusion > 100000 then
  569.                 ratio_fusion = 100000
  570.             end
  571.             fusion.setInjectionRate(ratio_fusion)
  572.         end
  573.         affboutons(x,y)
  574.     elseif x==1 and y==1 then
  575.         computer.pushSignal("quit")
  576.         term.setCursor(1,1)
  577.         return false
  578.     end
  579. end
  580.  
  581. local function onTimer(_,timer)
  582.     --lvl_dtfuel(65,21,15,3)
  583.     --barre_verticale(4,22,11,15,"    TRITIUM    ",3,bleu,jaune)
  584.     --barre_verticale(83,22,11,15,"   DEUTERIUM   ",3,rouge,vert)
  585.     --afflaser(2,45,98)
  586.     --ctrl_fusion(40,26)
  587.     return true
  588. end
  589.  
  590. event.listen("touch",onTouch)
  591. local timer = event.timer(.1,onTimer,math.huge)
  592. event.listen("redstone_changed", onRedstone)
  593. event.pull("quit")
  594. event.cancel(timer)
  595. event.ignore("touch",onTouch)
  596. event.ignore("redstone_changed", onRedstone)
  597.  
  598. rs.setBundledOutput(cmd,0,conversion_binaire_nombre(false))  -- laser gauche
  599. rs.setBundledOutput(cmd,1,conversion_binaire_nombre(false))  -- laser droite
  600. rs.setBundledOutput(cmd,2,conversion_binaire_nombre(false))  -- alim fusion en deutérium
  601. rs.setBundledOutput(cmd,3,conversion_binaire_nombre(false))  -- alim fusion en tritium
  602. rs.setBundledOutput(cmd,4,conversion_binaire_nombre(false))  -- alim fusion dt-fuel ou deut-trit
  603. rs.setBundledOutput(cmd,5,conversion_binaire_nombre(true))  -- alim fusion dt-fuel ou deut-trit
  604. rs.setBundledOutput(cmd,6,conversion_binaire_nombre(false))  -- alim cuve gauche dt-fuel
  605. rs.setBundledOutput(cmd,7,conversion_binaire_nombre(false))  -- alim cuve droite dt-fuel
  606. rs.setBundledOutput(cmd,8,conversion_binaire_nombre(true))  -- activation laser amplifier - lancement fusion
  607.   --rs.setBundledOutput(cmd,9,)  -- laser_pret activé dans fonction ctrl_fusion
  608. rs.setBundledOutput(cmd,11,conversion_binaire_nombre(false))  -- alim machinerie dt-fuel en tritium
  609. rs.setBundledOutput(cmd,14,conversion_binaire_nombre(false))  -- alim machinerie dt-fuel en deutérium
  610.  
  611. setColor(noir,blanc)
  612. gpu.setResolution(160,40)
  613. gpu.fill(1,1,160,50," ")
  614.  
  615. --Créé par sshikamaru. Vous avez le droit de l'utiliser mais pas de le distribuer.
Add Comment
Please, Sign In to add comment