summaryrefslogtreecommitdiff
path: root/api.lua
diff options
context:
space:
mode:
Diffstat (limited to 'api.lua')
-rw-r--r--api.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/api.lua b/api.lua
index 39f7f09..1cf05f9 100644
--- a/api.lua
+++ b/api.lua
@@ -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