View difference between Paste ID: gm0VHt6c and FjQB7rAa
SHOW: | | - or go back to the newest paste.
1
-- pastebin get xnyZ9E1U startup
2-
local mom = peripheral.wrap("monitor_102")
2+
m = peripheral.wrap("monitor_102")
3-
term.redirect(mom) -- redirige l'affichage sur mom
3+
--term.redirect(mom) -- redirige l'affichage sur mom
4-
somme = 0
4+
m.clear()
5-
maxt = 0
5+
6
local tableau_amount = {}
7-
tableau_amount = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,24,26,27,28,29}
7+
local tableau_max = {}
8-
tableau_max = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,24,26,27,28,29}
8+
local somme = 0
9
local maxt = 0
10
	
11
	
12
function DisplayEnergy(energy)
13-
function DisplayEnergy(energy,i)
13+
14
  	if peripheral.wrap(energy) ~= nil then
15
		local amount, max_energy
16-
  if peripheral.wrap(energy) ~= nil then
16+
		
17-
  local amount, max_energy, maxt, somme 
17+
		infos_energy = peripheral.wrap(energy)
18-
  infos_energy = peripheral.wrap(energy)
18+
19
 
20
		amount = infos_energy.getEnergyStored()
21-
  amount = infos_energy.getEnergyStored()
21+
		max_energy = infos_energy.getMaxEnergyStored()
22-
  max_energy = infos_energy.getMaxEnergyStored()
22+
		
23-
  tableau_amount[i] = amount 
23+
		if infos_energy.getEnergyStored() == nil then
24-
  tableau_max[i] = max_energy
24+
			amount = 0
25
		end
26
 
27
		if infos_energy.getMaxEnergyStored() == nil then
28
			max_energy = 0
29-
  if infos_energy.getEnergyStored() == nil then
29+
		end
30-
  amount = 0
30+
		
31-
  end
31+
		
32
		table.insert(tableau_amount,amount)
33-
  if infos_energy.getMaxEnergyStored() == nil then
33+
		table.insert(tableau_max,max_energy)
34-
  max_energy = 0
34+
		
35-
  end 
35+
	end
36-
  val_max = tableau_max[i]
36+
end
37-
  val_amount = tableau_amount[i]
37+
38-
  somme = somme + val_amount
38+
function affichervaleur()
39-
  maxt = maxt + val_max
39+
	somme = 0
40
	maxt = 0
41-
  --maxt = tableau_amount[1] + tableau_amount[2]+ tableau_amount[2]+ tableau_amount[2]+ tableau_amount[2]+ tableau_amount[2]+ tableau_amount[2]+ tableau_amount[2]
41+
42
	for i=1,#tableau_amount do
43-
  term.setCursorPos(1,1)
43+
	  somme = somme + tableau_amount[i]
44-
  term.setTextColor(16384)
44+
	end
45-
  print("STOCKAGE DE L'ENERGIE")
45+
46-
  term.setCursorPos(1,3)
46+
	for i=1,#tableau_max do
47-
  term.setTextColor(1)
47+
	 maxt = maxt + tableau_max[i]
48-
  print(somme.."/"..maxt)
48+
	end
49
	  
50
	  
51
	  
52
	  m.setCursorPos(1,1)
53-
  sleep(10)
53+
	  m.setTextColor(16384)
54
   m.setTextScale(1.2)
55-
  end
55+
   	  centerText("STOCKAGE DE L'ENERGIE")
56
	  m.setCursorPos(1,3)
57
	  m.setTextColor(1)
58-
  end
58+
	  centerText(somme.."/"..maxt)
59
60-
   while true do
60+
	  
61-
  term.clear()
61+
	 
62-
	mom.setTextScale(1)
62+
63
	  
64
end
65-
  DisplayEnergy("tile_thermalexpansion_cell_resonant_name_0",1)
65+
66-
  DisplayEnergy("tile_thermalexpansion_cell_resonant_name_1",2)
66+
function centerText(text)
67-
  DisplayEnergy("tile_thermalexpansion_cell_resonant_name_2",3)
67+
  x,y = m.getSize()
68-
  DisplayEnergy("tile_thermalexpansion_cell_resonant_name_3",4)
68+
  x1,y1 = m.getCursorPos()
69-
  DisplayEnergy("tile_thermalexpansion_cell_resonant_name_4",5)
69+
  m.setCursorPos((math.floor(x/2) - (math.floor(#text/2))), y1)
70-
  DisplayEnergy("tile_thermalexpansion_cell_resonant_name_5",6)
70+
  m.write(text)  
71-
  DisplayEnergy("tile_blockcapacitorbank_name_1",7)
71+
end
72-
  DisplayEnergy("tile_blockcapacitorbank_name_2",8)
72+
73-
  DisplayEnergy("tile_blockcapacitorbank_name_3",9)
73+
74-
  DisplayEnergy("tile_blockcapacitorbank_name_4",10)
74+
while true do
75-
  DisplayEnergy("tile_blockcapacitorbank_name_5",11)
75+
	tableau_amount = {}
76-
  DisplayEnergy("tile_blockcapacitorbank_name_6",12)
76+
	tableau_max = {}
77-
  DisplayEnergy("tile_blockcapacitorbank_name_7",13)
77+
78-
  DisplayEnergy("tile_blockcapacitorbank_name_9",13)
78+
  m.clear()
79-
  DisplayEnergy("tile_blockcapacitorbank_name_10",14)
79+
80-
  DisplayEnergy("tile_blockcapacitorbank_name_11",15)
80+
81-
  DisplayEnergy("tile_blockcapacitorbank_name_12",16)
81+
82-
  DisplayEnergy("tile_blockcapacitorbank_name_13",17)
82+
  DisplayEnergy("tile_thermalexpansion_cell_resonant_name_0")
83-
  DisplayEnergy("tile_blockcapacitorbank_name_14",18)
83+
  DisplayEnergy("tile_thermalexpansion_cell_resonant_name_1")
84
  DisplayEnergy("tile_thermalexpansion_cell_resonant_name_2")
85
  DisplayEnergy("tile_thermalexpansion_cell_resonant_name_3")
86
  DisplayEnergy("tile_thermalexpansion_cell_resonant_name_4")
87
  DisplayEnergy("tile_thermalexpansion_cell_resonant_name_5")
88
  DisplayEnergy("tile_blockcapacitorbank_name_40")
89
  DisplayEnergy("tile_blockcapacitorbank_name_37")
90
  DisplayEnergy("tile_blockcapacitorbank_name_3")
91-
  end
91+
  DisplayEnergy("tile_blockcapacitorbank_name_4")
92
  DisplayEnergy("tile_blockcapacitorbank_name_5")
93
  DisplayEnergy("tile_blockcapacitorbank_name_6")
94
  DisplayEnergy("tile_blockcapacitorbank_name_7")
95
  DisplayEnergy("tile_blockcapacitorbank_name_9")
96
  DisplayEnergy("tile_blockcapacitorbank_name_10")
97
  DisplayEnergy("tile_blockcapacitorbank_name_11")
98
  DisplayEnergy("tile_blockcapacitorbank_name_12")
99
  DisplayEnergy("tile_blockcapacitorbank_name_13")
100
  DisplayEnergy("tile_blockcapacitorbank_name_14")
101
  
102
 affichervaleur()
103
   
104
sleep(10)
105
106
end