245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
...
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
....
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
|
text = def.tex;
scale = def.scale;
alignment = def.align;
position = def.pos;
offset = def.ofs;
z_index = def.z;
}
if def.update then
img.update = function()
def.update(user, function(prop, val)
user:hud_change(img.id, prop, val)
end, def)
end
end
return img
end;
attachMeter = function(self, def)
local luser = self.entity
local m = {def = def}
local w = def.size or 80
local szf = w / 80
................................................................................
end
self:updateLEDs()
end;
updateLEDs = function(self)
local time = minetest.get_gametime()
local function updateSide(name, ofs, tx)
local del = {}
for i, l in ipairs(self.hud.led[name]) do
local idx = 0
if time - l.origin > 3 then
if l.elt then self.entity:hud_remove(l.elt.id) end
self.hud.led.map[l.kind] = nil
table.insert(del, i)
else
local xc = (idx*48 + 400)*ofs
if l.elt and next(del) then
l.elt:update('offset', {x=xc, y=1})
else
local tex = leds[l.kind].icon:blit(hudAdjustBacklight(leds[l.kind].bg))
if tx then tex = lib.image(tex:render()):transform(tx) end
if not l.elt then
l.elt = self:attachImage {
tex = tex:render();
align = {x=ofs, y=-1};
................................................................................
if time - self.cooldownTimes.alarm > 1.5 then
self.cooldownTimes.alarm = time
self:suitSound(urg.sound)
end
end
local newLed = {
kind = kind;
origin = time;
}
self.hud.led.map[kind] = newLed
table.insert(self.hud.led[led.side], newLed)
self:updateLEDs()
--[[
freq = freq or 3
local urgencies = {
[1] = {sound = 'starlit-alarm'};
|
|
<
<
|
<
|
<
>
>
>
<
|
>
|
|
<
<
|
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
...
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
....
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
|
text = def.tex;
scale = def.scale;
alignment = def.align;
position = def.pos;
offset = def.ofs;
z_index = def.z;
}
function img.chg(prop, val)
user:hud_change(img.id, prop, val)
end
img.update = def.update and function()
def.update(user, img.chg, def)
end or function() end
return img
end;
attachMeter = function(self, def)
local luser = self.entity
local m = {def = def}
local w = def.size or 80
local szf = w / 80
................................................................................
end
self:updateLEDs()
end;
updateLEDs = function(self)
local time = minetest.get_gametime()
local function updateSide(name, ofs, tx)
local del = {}
local idx = 0
for i, l in ipairs(self.hud.led[name]) do
if time - l.origin > 3 then
if l.elt then self.entity:hud_remove(l.elt.id) end
self.hud.led.map[l.kind] = nil
table.insert(del, i)
else
local xc = (idx*80 + 399)*ofs
if l.elt and next(del) then
l.elt.chg('offset', {x=xc, y=1})
else
local tex = leds[l.kind].icon:blit(hudAdjustBacklight(leds[l.kind].bg))
if tx then tex = lib.image(tex:render()):transform(tx) end
if not l.elt then
l.elt = self:attachImage {
tex = tex:render();
align = {x=ofs, y=-1};
................................................................................
if time - self.cooldownTimes.alarm > 1.5 then
self.cooldownTimes.alarm = time
self:suitSound(urg.sound)
end
end
local newLed = {
kind = kind;
origin = time;
}
self.hud.led.map[kind] = newLed
table.insert(self.hud.led[led.side], newLed)
self:updateLEDs()
--[[
freq = freq or 3
local urgencies = {
[1] = {sound = 'starlit-alarm'};
|