mirror of
https://github.com/appgurueu/hud_timers.git
synced 2024-08-20 12:54:06 +02:00
rolling-4
This commit is contained in:
parent
41ea2d4079
commit
0134d50136
11
main.lua
11
main.lua
@ -85,7 +85,7 @@ function add_timer(playername, timer_definition)
|
|||||||
{
|
{
|
||||||
hud_elem_type = "statbar",
|
hud_elem_type = "statbar",
|
||||||
position = hud_pos,
|
position = hud_pos,
|
||||||
size = "",
|
size = nil, -- intentionally set to nil
|
||||||
text = "hudbars_bar_background.png",
|
text = "hudbars_bar_background.png",
|
||||||
number = 2,
|
number = 2,
|
||||||
alignment = {x = 1, y = 1},
|
alignment = {x = 1, y = 1},
|
||||||
@ -97,7 +97,7 @@ function add_timer(playername, timer_definition)
|
|||||||
{
|
{
|
||||||
hud_elem_type = "statbar",
|
hud_elem_type = "statbar",
|
||||||
position = hud_pos,
|
position = hud_pos,
|
||||||
size = "",
|
size = nil, -- intentionally set to nil
|
||||||
text = "hud_timers_bar_timeout.png^[colorize:#" .. (timer_definition.color or "000000"),
|
text = "hud_timers_bar_timeout.png^[colorize:#" .. (timer_definition.color or "000000"),
|
||||||
number = 160,
|
number = 160,
|
||||||
alignment = {x = 1, y = 1},
|
alignment = {x = 1, y = 1},
|
||||||
@ -109,7 +109,7 @@ function add_timer(playername, timer_definition)
|
|||||||
{
|
{
|
||||||
hud_elem_type = "text",
|
hud_elem_type = "text",
|
||||||
position = hud_pos,
|
position = hud_pos,
|
||||||
size = "",
|
size = nil,
|
||||||
text = string.format(
|
text = string.format(
|
||||||
format,
|
format,
|
||||||
timer_definition.name,
|
timer_definition.name,
|
||||||
@ -135,8 +135,7 @@ function add_timer(playername, timer_definition)
|
|||||||
on_complete = timer_definition.on_complete,
|
on_complete = timer_definition.on_complete,
|
||||||
on_event = timer_definition.on_event,
|
on_event = timer_definition.on_event,
|
||||||
rounding_steps = timer_definition.rounding_steps or 10,
|
rounding_steps = timer_definition.rounding_steps or 10,
|
||||||
ids = {bg = bg_id, bar = bar_id, label = text_id},
|
ids = {bg = bg_id, bar = bar_id, label = text_id}
|
||||||
y_shift = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
table.insert(
|
table.insert(
|
||||||
@ -190,14 +189,12 @@ function maintain_timers(timers, dtime, player)
|
|||||||
string.format(format, timer.name, modlib.number.round(timer.time_left, timer.rounding_steps))
|
string.format(format, timer.name, modlib.number.round(timer.time_left, timer.rounding_steps))
|
||||||
)
|
)
|
||||||
player:hud_change(timer.ids.bar, "number", timer.time_left / timer.duration * 160)
|
player:hud_change(timer.ids.bar, "number", timer.time_left / timer.duration * 160)
|
||||||
if not (y_shift == 0) then
|
|
||||||
local y_offset = - (i-1) * 20
|
local y_offset = - (i-1) * 20
|
||||||
player:hud_change(timer.ids.bg, "offset", {x = 0, y = y_offset})
|
player:hud_change(timer.ids.bg, "offset", {x = 0, y = y_offset})
|
||||||
player:hud_change(timer.ids.bar, "offset", {x = 1, y = y_offset + 1})
|
player:hud_change(timer.ids.bar, "offset", {x = 1, y = y_offset + 1})
|
||||||
player:hud_change(timer.ids.label, "offset", {x = 2, y = y_offset})
|
player:hud_change(timer.ids.label, "offset", {x = 2, y = y_offset})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function update_timers(playername)
|
function update_timers(playername)
|
||||||
maintain_timers(timers[playername], 0, minetest.get_player_by_name(playername))
|
maintain_timers(timers[playername], 0, minetest.get_player_by_name(playername))
|
||||||
|
Loading…
Reference in New Issue
Block a user