1
0
mirror of https://gitlab.com/rubenwardy/awards.git synced 2024-09-22 01:20:18 +02:00

Fix bugs when player has achieved removed award

This commit is contained in:
rubenwardy 2014-09-26 19:52:10 +01:00
parent b75f2cbaea
commit fc950bb620

13
api.lua
View File

@ -347,10 +347,12 @@ function awards._order_awards(name)
local player = awards.player(name) local player = awards.player(name)
if player and player.unlocked then if player and player.unlocked then
for _,got in pairs(player.unlocked) do for _,got in pairs(player.unlocked) do
if awards.def[got] then
done[got] = true done[got] = true
table.insert(retval,{name=got,got=true}) table.insert(retval,{name=got,got=true})
end end
end end
end
for _,def in pairs(awards.def) do for _,def in pairs(awards.def) do
if not done[def.name] then if not done[def.name] then
table.insert(retval,{name=def.name,got=false}) table.insert(retval,{name=def.name,got=false})
@ -372,7 +374,8 @@ function awards.showto(name, to, sid, text)
for _, str in pairs(awards.players[name].unlocked) do for _, str in pairs(awards.players[name].unlocked) do
local def = awards.def[str] local def = awards.def[str]
if def and def.title then if def then
if def.title then
if def.description then if def.description then
minetest.chat_send_player(to, def.title..": "..def.description) minetest.chat_send_player(to, def.title..": "..def.description)
else else
@ -382,6 +385,7 @@ function awards.showto(name, to, sid, text)
minetest.chat_send_player(to, str) minetest.chat_send_player(to, str)
end end
end end
end
else else
if sid == nil or sid < 1 then if sid == nil or sid < 1 then
sid = 1 sid = 1
@ -408,6 +412,7 @@ function awards.showto(name, to, sid, text)
if item.got then if item.got then
status = " (got)" status = " (got)"
end end
local icon = ""
if def and def.icon then if def and def.icon then
icon = def.icon icon = def.icon
end end
@ -423,13 +428,14 @@ function awards.showto(name, to, sid, text)
formspec = formspec .. "textlist[4.75,0;6,5;awards;" formspec = formspec .. "textlist[4.75,0;6,5;awards;"
local first = true local first = true
for _,award in pairs(listofawards) do for _,award in pairs(listofawards) do
local def = awards.def[award.name]
if def then
if not first then if not first then
formspec = formspec .. "," formspec = formspec .. ","
end end
first = false first = false
local def = awards.def[award.name]
if def and def.secret and not award.got then if def.secret and not award.got then
formspec = formspec .. "#ACACACSecret Award" formspec = formspec .. "#ACACACSecret Award"
else else
local title = award.name local title = award.name
@ -443,6 +449,7 @@ function awards.showto(name, to, sid, text)
end end
end end
end end
end
formspec = formspec .. ";"..sid.."]" formspec = formspec .. ";"..sid.."]"
-- Show formspec to user -- Show formspec to user