Progressive Mode: minor fix + HUD bold text support

This commit is contained in:
Jean-Patrick Guerrero 2021-08-06 04:04:04 +02:00
parent c87a179cb5
commit e96d279d29

View File

@ -3229,6 +3229,7 @@ if progressive_mode then
number = 0xffffff, number = 0xffffff,
text = "", text = "",
z_index = 0xDEAD, z_index = 0xDEAD,
style = 1,
}, },
} }
end end
@ -3256,7 +3257,8 @@ if progressive_mode then
end end
player:hud_change(data.hud.text, "text", player:hud_change(data.hud.text, "text",
S("@1 new recipe(s) discovered!", data.discovered)) fmt("%u new recipe%s discovered!",
data.discovered, data.discovered > 1 and "s" or ""))
elseif data.show_hud == false then elseif data.show_hud == false then
if data.hud_timer >= HUD_TIMER_MAX then if data.hud_timer >= HUD_TIMER_MAX then
@ -3314,19 +3316,17 @@ if progressive_mode then
poll_new_items() poll_new_items()
if singleplayer then
core.register_globalstep(function() core.register_globalstep(function()
local players = core.get_connected_players() local name = "singleplayer"
local player = core.get_player_by_name(name)
for i = 1, #players do
local player = players[i]
local name = player:get_player_name()
local data = pdata[name] local data = pdata[name]
if data and data.show_hud ~= nil and singleplayer then if data and data.show_hud ~= nil then
show_hud_success(player, data) show_hud_success(player, data)
end end
end
end) end)
end
i3.add_recipe_filter("Default progressive filter", progressive_filter) i3.add_recipe_filter("Default progressive filter", progressive_filter)
@ -3338,12 +3338,19 @@ if progressive_mode then
data.inv_items = data.inv_items or {} data.inv_items = data.inv_items or {}
data.known_recipes = data.known_recipes or 0 data.known_recipes = data.known_recipes or 0
local oldknown = data.known_recipes
local items = get_filtered_items(player, data) local items = get_filtered_items(player, data)
data.discovered = data.known_recipes - oldknown
data.items_raw = items data.items_raw = items
search(data) search(data)
if singleplayer then if singleplayer then
init_hud(player, data) init_hud(player, data)
if data.show_hud == nil and data.discovered > 0 then
data.show_hud = true
end
end end
end) end)
end end