123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- function sabotage.show_hud_timed(map_id, timer, desc)
- for _, player in pairs(minetest.get_connected_players()) do
- local name = player:get_player_name()
- local id = lobby.game[name]
- if id == map_id or id == map_id..'_ghost' then
- sabotage.hud[name] = {
- desc = player:hud_add({
- hud_elem_type = 'text',
- position = {x = 1, y = 0.125},
- offset = {x = -20, y = -20},
- text = 'Find '..desc,
- alignment = {x = -1, y = 0},
- scale = {x = 100, y = 100},
- }),
- title = player:hud_add({
- hud_elem_type = 'text',
- position = {x = 1, y = 0.125},
- offset = {x = -20, y = 0},
- text = 'Time until sabotage ends:',
- alignment = {x = -1, y = 0},
- scale = {x = 100, y = 100},
- }),
- timer = player:hud_add({
- hud_elem_type = 'text',
- position = {x = 1, y = 0.125},
- offset = {x = -60, y = 20},
- text = timer..' seconds',
- alignment = {x = -1, y = 0},
- scale = {x = 100, y = 100},
- })
- }
- end
- end
- minetest.after(1, function()
- sabotage.update_hud(map_id)
- end)
- end
- function sabotage.clear_hud(map_id)
- for _, player in pairs(minetest.get_connected_players()) do
- local name = player:get_player_name()
- local id = lobby.game[name]
- if id == map_id or id == map_id..'_ghost' then
- local idx = sabotage.hud[name]
- for key,value in pairs(idx) do
- player:hud_remove(value)
- end
- end
- end
- end
- function sabotage.update_hud(map_id)
- local time = sabotage.timer[map_id] - 1
- if time < 0 then
- sabotage.clear_hud(map_id)
- sabotage.finish(map_id)
- return
- end
- sabotage.timer[map_id] = time
- for _, player in pairs(minetest.get_connected_players()) do
- local name = player:get_player_name()
- local id = lobby.game[name]
- if id == map_id or id == map_id..'_ghost' then
- local idx = sabotage.hud[name]
- player:hud_change(idx.timer, 'text', time..' seconds')
- end
- end
- minetest.after(1, function()
- sabotage.update_hud(map_id)
- end)
- end
- function sabotage.show_hud(map_id, desc)
- for _, player in pairs(minetest.get_connected_players()) do
- local name = player:get_player_name()
- local id = lobby.game[name]
- if id == map_id or id == map_id..'_ghost' then
- sabotage.hud[name] = {
- desc = player:hud_add({
- hud_elem_type = 'text',
- position = {x = 1, y = 0.125},
- offset = {x = -20, y = -20},
- text = 'Find '..desc,
- alignment = {x = -1, y = 0},
- scale = {x = 100, y = 100},
- }),
- title = player:hud_add({
- hud_elem_type = 'text',
- position = {x = 1, y = 0.125},
- offset = {x = -20, y = 0},
- text = 'Items still require repairs!!!',
- alignment = {x = -1, y = 0},
- scale = {x = 100, y = 100},
- }),
- }
- end
- end
- end
|