1
0
mirror of https://gitlab.com/rubenwardy/awards.git synced 2024-11-13 22:30:16 +01:00

Add awards.remove(..) util

This commit is contained in:
marco_a 2024-04-30 16:52:59 +02:00
parent c4709de60f
commit 457eedb913
2 changed files with 17 additions and 0 deletions

View File

@ -197,6 +197,8 @@ end
* return true to cancel HUD from appearing.
* `awards.unlock(player_name, award_name)`
* gives an award to a player
* `awards.remove(player_name, award_name)`
* removes an award from a player
* `awards.get_award_states(player_name)`
* Returns list of tables, sorted by `score`, each having the fields:

View File

@ -183,6 +183,21 @@ function awards.unlock(name, award)
end
end
function awards.remove(name, award)
local data = awards.player(name)
local awdef = awards.registered_awards[award]
assert(awdef, "Unable to remove an award which doesn't exist!")
if data.disabled or
(not data.unlocked[award]) then
return
end
minetest.log("action", "Award " .. award .." has been removed from ".. name)
data.unlocked[award] = nil
awards.save()
end
function awards.get_award_states(name)
local hash_is_unlocked = {}
local retval = {}