diff options
Diffstat (limited to 'api.lua')
-rw-r--r-- | api.lua | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -296,6 +296,19 @@ function awards.register_achievement(name, def) tdef:on_register(def) end + function def:can_unlock(data) + if not self.requires then + return true + end + + for i=1, #self.requires do + if not data.unlocked[self.requires[i]] then + return false + end + end + return true + end + -- Add Award awards.registered_awards[name] = def @@ -341,6 +354,12 @@ function awards.unlock(name, award) return end + if not awdef:can_unlock(data) then + minetest.log("warning", "can_unlock returned false in unlock of " .. + award .. " for " .. name) + return + end + -- Unlock Award minetest.log("action", name.." has unlocked award "..name) data.unlocked[award] = award |