Order hint completion alerts chronologically

Instead of sorting hint completion alerts alphabetically
just so they'll be stable, sort them by order of actual
completion, so most recently completed hints are at
the bottom of the list, instead of inserted at randomish
places in the list.
This commit is contained in:
Aaron Suen 2021-08-14 08:37:06 -04:00
parent 5639ec773c
commit fb66115fb1

View File

@ -43,14 +43,18 @@ nodecore.register_playerstep({
local mc = msgcache[data.pname] or {}
local t = {}
local o = {}
for k, v in pairs(mc) do
if v < nodecore.gametime then
mc[k] = nil
else
t[#t + 1] = nodecore.translate(msg, k)
o[t[#t]] = v
end
end
table_sort(t)
table_sort(t, function(a, b)
return o[a] < o[b] or o[a] == o[b] and a < b
end)
nodecore.hud_set_multiline(player, {
label = "hintcomplete",
hud_elem_type = "text",