-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorageMonitor.lua
More file actions
600 lines (575 loc) · 22 KB
/
storageMonitor.lua
File metadata and controls
600 lines (575 loc) · 22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
--[[
StorageMonitor program
By Out-Feu
version 1.6.0
Free to distribute/alter
so long as proper credit to original
author is maintained.
This program will display on a monitor the storage of all connected storage blocks (item, liquid, RF...).
Multiple monitors can be connected.
--]]
table.find = function(self, search)
for index, value in pairs(self) do
if value == search then
return index
end
end
return nil
end
table.findAll = function(self, searchTable)
for i, search in pairs(searchTable) do
local found = false
for index, value in pairs(self) do
if value == search then
found = true
break
end
end
if not found then
return false
end
end
return true
end
math.floorDecimal = function(num, precision)
local power = 10 ^ math.abs(precision)
if precision < 0 then
return math.floor(num / power) * power
else
return math.floor(num * power) / power
end
end
function formatNumber(num)
local abreviation = ""
if useAbreviation then
local n = 1
while num >= 1000 and n <= #abreviationList do
num = num / 1000
abreviation = abreviationList[n]
n = n + 1
end
end
return math.floorDecimal(num, decimalPrecision) .. abreviation .. " " .. storageType
end
function getCurrentStorage()
local currentStorage = 0
local storageCapacity = 0
for i, storage in pairs(storageRF) do
storageCapacity = storage.getEnergy()
if storageCapacity ~= nil then
currentStorage = currentStorage + storageCapacity
end
end
for i, storage in pairs(storageRFMeka) do
storageCapacity = storage.getEnergy()
if storageCapacity ~= nil then
currentStorage = currentStorage + math.floor(storageCapacity * 0.4)
end
end
for i, storage in pairs(storageRFAE) do
storageCapacity = storage.getEnergyStorage()
if storageCapacity ~= nil then
currentStorage = currentStorage + (storageCapacity * 2)
end
end
for i, storage in pairs(storageRFRS) do
storageCapacity = storage.getEnergyStorage()
if storageCapacity ~= nil then
currentStorage = currentStorage + storageCapacity
end
end
for i, storage in pairs(storageEU) do
storageCapacity = storage.getEUStored()
if storageCapacity ~= nil then
currentStorage = currentStorage + storageCapacity
end
end
for i, storage in pairs(storagePressure) do
storageCapacity = storage.getPressure()
if storageCapacity ~= nil then
currentStorage = currentStorage + storageCapacity
end
end
for i, storage in pairs(storageMana) do
storageCapacity = storage.getMana()
if storageCapacity ~= nil then
currentStorage = currentStorage + storageCapacity
end
end
for i, storage in pairs(storageFluid) do
local tanks = storage.tanks()
if tanks ~= nil then
for n, tank in pairs(tanks) do
currentStorage = currentStorage + tank.amount
end
end
end
for i, storage in pairs(storageFluidMeka) do
if storage.getCapacity ~= nil then
storageCapacity = storage.getCapacity()
elseif storage.getTankCapacity ~= nil then
storageCapacity = storage.getTankCapacity()
elseif storage.getChemicalTankCapacity ~= nil then
storageCapacity = storage.getChemicalTankCapacity()
end
if storageCapacity ~= nil then
if storage.getNeeded ~= nil then
local storageNeeded = storage.getNeeded()
if storageNeeded ~= nil then
currentStorage = currentStorage + storageCapacity - storageNeeded
end
elseif storage.getFilledPercentage ~= nil then
local storagePercent = storage.getFilledPercentage()
if storagePercent ~= nil then
currentStorage = currentStorage + storageCapacity * storagePercent
end
end
end
end
for i, storage in pairs(storageFluidAE) do
storageCapacity = storage.getUsedFluidStorage()
if storageCapacity ~= nil then
currentStorage = currentStorage + storageCapacity
end
end
for i, storage in pairs(storageFluidRS) do
local fluids = storage.listFluids()
if fluids ~= nil then
for n, fluid in pairs(fluids) do
currentStorage = currentStorage + fluid.amount
end
end
end
for i, storage in pairs(storageItem) do
local items = storage.list()
if items ~= nil then
for n, item in pairs(items) do
currentStorage = currentStorage + item.count
end
end
end
for i, storage in pairs(storageItemAE) do
storageCapacity = storage.getUsedItemStorage()
if storageCapacity ~= nil then
currentStorage = currentStorage + storageCapacity
end
end
for i, storage in pairs(storageItemRS) do
local items = storage.listItems()
if items ~= nil then
for n, item in pairs(items) do
currentStorage = currentStorage + item.amount
end
end
end
for i, storage in pairs(storageQIO) do
if storage.hasFrequency() then
storageCapacity = storage.getFrequencyItemCount()
if storageCapacity ~= nil then
currentStorage = currentStorage + storageCapacity
end
end
end
return currentStorage
end
function getMaxStorage()
if forceMaxStorage ~= nil then
return forceMaxStorage
end
local maxStorage = 0
local storageCapacity = 0
for i, storage in pairs(storageRF) do
storageCapacity = storage.getEnergyCapacity()
if storageCapacity ~= nil then
maxStorage = maxStorage + storageCapacity
end
end
for i, storage in pairs(storageRFMeka) do
storageCapacity = storage.getMaxEnergy()
if storageCapacity ~= nil then
maxStorage = maxStorage + math.floor(storageCapacity * 0.4)
end
end
for i, storage in pairs(storageRFAE) do
storageCapacity = storage.getMaxEnergyStorage()
if storageCapacity ~= nil then
maxStorage = maxStorage + (storageCapacity * 2)
end
end
for i, storage in pairs(storageRFRS) do
storageCapacity = storage.getMaxEnergyStorage()
if storageCapacity ~= nil then
maxStorage = maxStorage + storageCapacity
end
end
for i, storage in pairs(storageEU) do
storageCapacity = storage.getEUCapacity()
if storageCapacity ~= nil then
maxStorage = maxStorage + storageCapacity
end
end
for i, storage in pairs(storagePressure) do
storageCapacity = storage.getDangerPressure()
if storageCapacity ~= nil then
maxStorage = maxStorage + storageCapacity
end
end
for i, storage in pairs(storageMana) do
storageCapacity = storage.getMaxMana()
if storageCapacity ~= nil then
maxStorage = maxStorage + storageCapacity
end
end
for i, storage in pairs(storageFluid) do
local tanks = storage.tanks()
if tanks ~= nil then
for n, tank in pairs(tanks) do
if tank.capacity ~= nil then
maxStorage = maxStorage + tank.capacity
else
maxStorage = maxStorage + tank.amount
end
end
end
end
for i, storage in pairs(storageFluidMeka) do
if storage.getCapacity ~= nil then
storageCapacity = storage.getCapacity()
elseif storage.getTankCapacity ~= nil then
storageCapacity = storage.getTankCapacity()
elseif storage.getChemicalTankCapacity ~= nil then
storageCapacity = storage.getChemicalTankCapacity()
end
if storageCapacity ~= nil then
maxStorage = maxStorage + storageCapacity
end
end
for i, storage in pairs(storageFluidAE) do
storageCapacity = storage.getTotalFluidStorage()
if storageCapacity ~= nil then
maxStorage = maxStorage + storageCapacity
end
end
for i, storage in pairs(storageFluidRS) do
storageCapacity = storage.getMaxFluidDiskStorage()
if storageCapacity ~= nil then
maxStorage = maxStorage + storageCapacity
end
storageCapacity = storage.getMaxFluidExternalStorage()
if storageCapacity ~= nil then
maxStorage = maxStorage + storageCapacity
end
end
for i, storage in pairs(storageItem) do
local storageSize = storage.size()
if storageSize ~= nil then
for n = 1, storageSize do
local item = storage.getItemDetail(n)
if item ~= nil and item.count <= item.maxCount then
maxStorage = maxStorage + item.maxCount
elseif storage.getItemLimit(n) ~= nil then
maxStorage = maxStorage + storage.getItemLimit(n)
end
end
end
end
for i, storage in pairs(storageItemAE) do
storageCapacity = storage.getTotalItemStorage()
if storageCapacity ~= nil then
maxStorage = maxStorage + storageCapacity
end
end
for i, storage in pairs(storageItemRS) do
storageCapacity = storage.getMaxItemDiskStorage()
if storageCapacity ~= nil then
maxStorage = maxStorage + storageCapacity
end
storageCapacity = storage.getMaxItemExternalStorage()
if storageCapacity ~= nil then
maxStorage = maxStorage + storageCapacity
end
end
for i, storage in pairs(storageQIO) do
if storage.hasFrequency() then
storageCapacity = storage.getFrequencyItemCapacity()
if storageCapacity ~= nil then
maxStorage = maxStorage + storageCapacity
end
end
end
return maxStorage
end
function updateStorageCapacity(forceUpdateCapacity)
if forceUpdateCapacity or updateCapacity then
currentMaxStorage = getMaxStorage()
end
currentStorage = getCurrentStorage()
if currentMaxStorage == 0 then
currentPercent = 0
else
currentPercent = currentStorage / currentMaxStorage
end
end
function findStorageType()
if forceStorageType ~= nil and forceStorageType ~= "" then
return forceStorageType
end
local types = { (#storageRF + #storageRFMeka + #storageRFAE + #storageRFRS), #storageEU, #storagePressure, #storageMana, (#storageFluid + #storageFluidMeka + #storageFluidRS), (#storageItem + #storageItemRS + #storageQIO), (#storageItemAE + #storageFluidAE) }
local nType = 0
for i, type in pairs(types) do
if type > 0 then
nType = nType + 1
end
end
if nType == 1 then
if #storageRF > 0 or #storageRFMeka > 0 or #storageRFAE > 0 or #storageRFRS > 0 then
return "RF"
elseif #storageEU > 0 then
return "EU"
elseif #storagePressure > 0 then
return "Bar"
elseif #storageMana > 0 then
return "Mana"
elseif #storageFluid > 0 or #storageFluidMeka > 0 or #storageFluidRS > 0 then
return "mB"
elseif #storageItem > 0 or #storageItemRS > 0 or #storageQIO > 0 then
return "Item"
elseif #storageItemAE > 0 or #storageFluidAE > 0 then
return "Bytes"
end
end
return ""
end
function findConnectedPeripherals(resetAll)
if resetAll then
nStorage = 0
monitors = {}
storageRF = {}
storageRFMeka = {}
storageRFAE = {}
storageRFRS = {}
storageEU = {}
storagePressure = {}
storageMana = {}
storageFluid = {}
storageFluidMeka = {}
storageFluidAE = {}
storageFluidRS = {}
storageItem = {}
storageItemAE = {}
storageItemRS = {}
storageQIO = {}
end
local peripherals = peripheral.getNames()
for i, per in pairs(peripherals) do
if peripheral.getType(per) == "monitor" then
table.insert(monitors, peripheral.wrap(per))
elseif table.findAll(peripheral.getMethods(per), {"getEnergy", "getEnergyCapacity"}) and table.find({nil, "", "RF", "FE", "AE"}, forceStorageType) ~= nil then
table.insert(storageRF, peripheral.wrap(per))
elseif table.findAll(peripheral.getMethods(per), {"getEnergy", "getMaxEnergy"}) and table.find({nil, "", "RF", "FE", "AE"}, forceStorageType) ~= nil then
table.insert(storageRFMeka, peripheral.wrap(per))
elseif table.findAll(peripheral.getMethods(per), {"getEUStored", "getEUCapacity"}) and table.find({nil, "", "EU"}, forceStorageType) ~= nil then
table.insert(storageEU, peripheral.wrap(per))
elseif table.findAll(peripheral.getMethods(per), {"getPressure", "getDangerPressure"}) and table.find({nil, "", "Bar", "Air", "Pressure"}, forceStorageType) ~= nil then
table.insert(storagePressure, peripheral.wrap(per))
elseif table.findAll(peripheral.getMethods(per), {"getMana", "getMaxMana"}) and table.find({nil, "", "Mana"}, forceStorageType) ~= nil then
table.insert(storageMana, peripheral.wrap(per))
elseif table.findAll(peripheral.getMethods(per), {"hasFrequency", "getFrequencyItemCount", "getFrequencyItemCapacity"}) and table.find({nil, "", "Item"}, forceStorageType) ~= nil then
table.insert(storageQIO, peripheral.wrap(per))
elseif table.findAll(peripheral.getMethods(per), {"tanks"}) and table.find({nil, "", "mB", "Liquid", "Fluid", "Gas", "Blood"}, forceStorageType) ~= nil then
table.insert(storageFluid, peripheral.wrap(per))
elseif table.find(peripheral.getMethods(per), "getStored") and (table.find(peripheral.getMethods(per), "getCapacity") or table.find(peripheral.getMethods(per), "getTankCapacity") or table.find(peripheral.getMethods(per), "getChemicalTankCapacity")) and (table.find(peripheral.getMethods(per), "getNeeded") or table.find(peripheral.getMethods(per), "getFilledPercentage")) and table.find({nil, "", "mB", "Liquid", "Fluid", "Gas", "Blood"}, forceStorageType) ~= nil then
table.insert(storageFluidMeka, peripheral.wrap(per))
elseif table.findAll(peripheral.getMethods(per), {"getTotalItemStorage", "getUsedItemStorage", "getTotalFluidStorage", "getUsedFluidStorage"}) and table.find({nil, "", "Bytes"}, forceStorageType) ~= nil then
table.insert(storageItemAE, peripheral.wrap(per))
table.insert(storageFluidAE, peripheral.wrap(per))
elseif table.findAll(peripheral.getMethods(per), {"getTotalItemStorage", "getUsedItemStorage"}) and table.find({nil, "", "Item"}, forceStorageType) ~= nil then
table.insert(storageItemAE, peripheral.wrap(per))
elseif table.findAll(peripheral.getMethods(per), {"getTotalFluidStorage", "getUsedFluidStorage"}) and table.find({nil, "", "mB", "Liquid", "Fluid", "Gas", "Blood"}, forceStorageType) ~= nil then
table.insert(storageFluidAE, peripheral.wrap(per))
elseif table.find(peripheral.getMethods(per), "listItems") and (table.find(peripheral.getMethods(per), "getMaxItemDiskStorage") or table.find(peripheral.getMethods(per), "getMaxItemExternalStorage")) and table.find({nil, "", "Item"}, forceStorageType) ~= nil then
table.insert(storageItemRS, peripheral.wrap(per))
elseif table.find(peripheral.getMethods(per), "listFluids") and (table.find(peripheral.getMethods(per), "getMaxFluidDiskStorage") or table.find(peripheral.getMethods(per), "getMaxFluidExternalStorage")) and table.find({nil, "", "mB", "Liquid", "Fluid", "Gas", "Blood"}, forceStorageType) ~= nil then
table.insert(storageFluidRS, peripheral.wrap(per))
elseif table.findAll(peripheral.getMethods(per), {"getMaxEnergyStorage", "getEnergyStorage"}) and table.find({nil, "", "RF", "FE", "AE"}, forceStorageType) ~= nil then
if table.find(peripheral.getMethods(per), "getCraftingCPUs") then
table.insert(storageRFAE, peripheral.wrap(per))
else
table.insert(storageRFRS, peripheral.wrap(per))
end
elseif table.findAll(peripheral.getMethods(per), {"size", "list", "getItemLimit", "getItemDetail"}) and table.find({nil, "", "Item"}, forceStorageType) ~= nil then
table.insert(storageItem, peripheral.wrap(per))
elseif peripheral.getType(per) ~= "modem" then
printError("Found unsupported peripheral: " .. peripheral.getType(per))
end
end
nStorage = #storageRF + #storageRFMeka + #storageRFAE + #storageRFRS + #storageEU + #storagePressure + #storageMana + #storageFluid + #storageFluidAE + #storageFluidRS + #storageFluidMeka + #storageItem + #storageItemAE + #storageItemRS + #storageQIO
print("Found " .. #monitors .. " monitors and " .. nStorage .. " storage peripherals")
end
function initStorageColor()
if storageFillColor ~= nil then
return
elseif storageType == "RF" or storageType == "FE" then
if #storageRFMeka > 0 and #storageRF == 0 then
storageFillColor = colors.green
storageFillColorAlt = colors.lime
else
storageFillColor = colors.red
storageFillColorAlt = colors.pink
end
elseif storageType == "EU" or storageType == "mB" or storageType == "Liquid" or storageType == "Fluid" or storageType == "Gas" or storageType == "Mana" then
storageFillColor = colors.blue
storageFillColorAlt = colors.lightBlue
elseif storageType == "Blood" then
storageFillColor = colors.red
storageFillColorAlt = colors.pink
elseif storageType == "Bar" or storageType == "Air" or storageType == "Pressure" then
storageFillColor = colors.green
storageFillColorAlt = colors.lime
elseif storageType == "Bytes" then
storageFillColor = colors.cyan
storageFillColorAlt = colors.lightBlue
elseif storageType == "Item" then
if #storageQIO > 0 and #storageItem == 0 then
storageFillColor = colors.green
storageFillColorAlt = colors.lime
elseif #storageItemRS > 0 and #storageItem == 0 then
storageFillColor = colors.cyan
storageFillColorAlt = colors.lightBlue
else
storageFillColor = colors.brown
storageFillColorAlt = colors.orange
end
else
storageFillColor = colors.white
storageFillColorAlt = colors.lightGray
end
end
--------------------------------------------------------------------------------
textColor = colors.white --color of the text
backgroundColor = colors.black --background color of the program
transfertPlusColor = colors.green --color of the text for positive transfer
transfertMinusColor = colors.red --color of the text for negative transfer
storageBackgroundColor = colors.gray --color for empty storage space
storageFillColor = nil --color for full storage, set to nil to automatically set the color depending on storage type
storageFillColorAlt = nil --transition color for half full storage, set to nil to automatically set the color depending on storage type
displayTotalStorage = true --display the total storage
displayCurrentStorage = true --display the current storage
displayStorageTransfert = true --display the difference of the current storage per tick
displayStoragePercent = true --display the fill percentage of the storage
paddingAll = 1 --padding on all the sides of the monitor
paddingSide = 0 --extra padding on the left and on the right of the storage space display
decimalPrecision = 2 --maximum number of decimal to display on storage capacity
useAbreviation = true --use abreviations on storage capacity
forceStorageType = "" --if set, all other connected storage type will be ignored
forceMaxStorage = nil --if set, the max storage will not be calculated and this value will be used instead
updateFrequency = 1 --how often should the display be updated (in seconds)
updateLatency = 2 --number of ticks to add per connected storage when calculating the transfer rate
updateCapacity = false --should the total capacity be updated a the same time as the current storage
abreviationList = { "K", "M", "B", "T" } --each subsequent symbol must be equal to it's predecessor x1000
storageRF = {}
storageRFMeka = {}
storageRFAE = {}
storageRFRS = {}
storageMana = {}
storageEU = {}
storagePressure = {}
storageItem = {}
storageItemAE = {}
storageItemRS = {}
storageQIO = {}
storageFluid = {}
storageFluidMeka = {}
storageFluidAE = {}
storageFluidRS = {}
monitors = {}
storageType = ""
--------------------------------------------------------------------------------
findConnectedPeripherals(false)
storageType = findStorageType()
initStorageColor()
currentTransfert = 0
updateStorageCapacity(true)
currentTimer = os.startTimer(updateFrequency)
repeat --main loop
--display storage on the monitors
for index, monitor in pairs(monitors) do
local w, h = monitor.getSize()
monitor.setTextColour(textColor)
monitor.setBackgroundColor(backgroundColor)
monitor.clear()
paddingTop = 1 + paddingAll
if displayTotalStorage then
monitor.setCursorPos(1 + paddingAll, paddingTop)
monitor.write("Capacity: " .. formatNumber(currentMaxStorage))
paddingTop = paddingTop + 1
end
if displayCurrentStorage then
monitor.setCursorPos(1 + paddingAll, paddingTop)
monitor.write("Stored: " .. formatNumber(currentStorage))
paddingTop = paddingTop + 1
end
if displayStorageTransfert then
monitor.setCursorPos(1 + paddingAll, paddingTop)
monitor.write("Transfer: ")
if currentTransfert == 0 then
monitor.write(" " .. formatNumber(currentTransfert) .. "/t")
elseif currentTransfert > 0 then
monitor.setTextColour(transfertPlusColor)
monitor.write("+" .. formatNumber(currentTransfert) .. "/t")
else
monitor.setTextColour(transfertMinusColor)
monitor.write(formatNumber(currentTransfert) .. "/t")
end
paddingTop = paddingTop + 1
end
if displayTotalStorage or displayCurrentStorage or displayStorageTransfert then
paddingTop = paddingTop + 1
end
local height = h - paddingTop - paddingAll
local width = w - (paddingAll * 2) - (paddingSide * 2)
local lenPercent = height - (height * currentPercent)
for n = 0, height do
if n < lenPercent or (n == height and currentPercent <= 0) then
monitor.setBackgroundColor(storageBackgroundColor)
elseif storageFillColorAlt ~= nil and n == math.ceil(lenPercent) and currentPercent < 1 and n - lenPercent < 0.5 then
monitor.setBackgroundColor(storageFillColorAlt)
else
monitor.setBackgroundColor(storageFillColor)
end
monitor.setCursorPos(1 + paddingAll + paddingSide, paddingTop + n)
monitor.write(string.rep(" ", width))
if displayStoragePercent and n == math.floor(height / 2) then
local padingPercent = width / 2
if currentPercent < 10 then
padingPercent = padingPercent - 1
elseif currentPercent < 100 then
padingPercent = padingPercent - 1.5
else
padingPercent = padingPercent - 2
end
monitor.setTextColour(textColor)
monitor.setCursorPos(1 + paddingAll + paddingSide + padingPercent, paddingTop + n)
monitor.write(math.floor(currentPercent * 100) .. "%")
end
end
end
--wait for event
local event
repeat
event = os.pullEvent()
until event == "timer" or event == "peripheral" or event == "peripheral_detach" or event == "monitor_resize"
if event == "timer" then
local oldStorage = currentStorage
updateStorageCapacity(false)
currentTransfert = (currentStorage - oldStorage) / ((updateFrequency * 20) + updateLatency * nStorage)
elseif event == "peripheral" or event == "peripheral_detach" then
findConnectedPeripherals(true)
storageType = findStorageType()
updateStorageCapacity(true)
else
updateStorageCapacity(false)
end
os.cancelTimer(currentTimer)
currentTimer = os.startTimer(updateFrequency)
until false