-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhud.lua
130 lines (115 loc) · 3.83 KB
/
hud.lua
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
local sides = require("sides")
local event = require("event")
local com = require("component")
local serialization = require("serialization")
local default = {
offsetX = 0,
offsetY = 0,
reactor = false,
redstone = false,
tankTritium = false,
redstoneSide = false,
laserAmplifier = false,
tankDeuterium = false,
glassesTerminal = false,
inductionMatrix = false,
laIgnitionEnergy = 1250000
}
local buttons = {}
local status = {
maxEnergy = 0,
maxCaseHeat = 0,
imMaxStorage = 0,
maxPlasmaHeat = 0,
maxEnergyStored = 0,
laMaxEnergyStored = 0
}
local statusbox = {}
statusbox.widgets = {}
local injectionRateWidget = {}
function initComponents()
for address,type in pairs(component.list("glasses")) do
if default.glassesTerminal == false then
print("íàéäåííûé òåðìèíàë äëÿ î÷êîâ "..address)
default.glassesTerminal = component.proxy(address)
else
print("íàéäåí äðóãîé òåðìèíàë äëÿ î÷êîâ ("..address.."). áóäåò èñïîëüçîâàòüñÿ ïåðâûé.")
end
end
for address,type in pairs(component.list("reactor_logic_adapter")) do
if default.reactor == false then
print("íàéäåí ðåàêòîð "..address)
default.reactor = component.proxy(address)
else
print("íàéäåí äðóãîé ðåàêòîð ("..address.."). áóäåò èñïîëüçîâàí ïåðâûé.")
end
end
for address,type in pairs(component.list("laser_amplifier")) do
if default.laserAmplifier == false then
print("íàéäåí ëàçåðíûé óñèëèòåëü "..address)
default.laserAmplifier = component.proxy(address)
else
print("íàéäåí äðóãîé ëàçåðíûé óñèëèòåëü ("..address.."). áóäåò èñïîëüçîâàí ïåðâûé.")
end
end
for address,type in pairs(component.list("redstone")) do
if default.redstone == false then
print("íàéäåí èíòåðôåéñ redstone "..address)
default.redstone = component.proxy(address)
else
print("íàøåë äðóãîé èíòåðôåéñ redstone ("..address.."). áóäåò èñïîëüçîâàí ïåðâûé.")
end
end
for address,type in pairs(component.list("induction_matrix")) do
if default.inductionMatrix == false then
print("íàéäåííàÿ èíäóêöèîííàÿ ìàòðèöà "..address)
default.inductionMatrix = component.proxy(address)
else
print("íàøåë äðóãóþ èíäóêöèîííóþ ìàòðèöó("..address.."). áóäåò èñïîëüçîâàí ïåðâàÿ.")
end
end
for address,type in pairs(component.list("_gas_tank")) do
checkTank(address)
os.sleep(0)
end
end
function val2perc(val, maxVal)
if(maxVal == 0) then return 0; end
return (math.floor(0.5 + ((val/maxVal) * 100)*10)/10)
end
function readTankFull(address)
local tank = component.proxy(address)
return {
gas = tank.getGas().label,
amount = tank.getStoredGas(),
maxAmount = tank.getMaxGas(),
tankType = tank.type }
end
function readTankStorage(tank)
return {
amount = tank.getStoredGas(),
maxAmount = tank.getMaxGas()
}
end
function checkTank(address)
local tankData = readTankFull(address)
if tankData.gas == nil then tankData.gas = "unknown"; end
print("# found ".. tankData.tankType .. " with " .. tankData.amount .. "/" .. tankData.maxAmount .. " of " .. tankData.gas)
if string.match(tankData.gas, "deuterium") then
print(" ... äîáàâëåíèå ðåçåðâóàðà ñ àäðåñîì " .. address)
if default.tankDeuterium == false then
default.tankDeuterium = component.proxy(address)
else
print("íàéäåíî áîëåå îäíîãî áàëëîíà ñ äåéòåðèåâûì ãàçîì, èñïîëüçóÿ ïåðâûé íàéäåííûé")
print("çàäàéòå àäðåñ â ñêðèïòå äëÿ èñïîëüçîâàíèÿ îïðåäåëåííîãî ïîëüçîâàòåëåì ðåçåðâóàðà")
end
elseif string.match(tankData.gas, "tritium") then
print(" ... äîáàâëåíèå ðåçåðâóàðà ñ àäðåñîì".. address)
if default.tankTritium == false then
default.tankTritium = component.proxy(address)
else
print("íàéäåíî áîëåå îäíîãî áàëëîíà ñ òðèòèåâûì ãàçîì, èñïîëüçóÿ ïåðâûé íàéäåííûé")
print("çàäàéòå àäðåñ â ñêðèïòå äëÿ èñïîëüçîâàíèÿ îïðåäåëåííîãî ïîëüçîâàòåëåì ðåçåðâóàðà")
end
end
end