diff options
author | rubenwardy <rw@rubenwardy.com> | 2018-04-05 17:00:41 +0100 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2018-04-05 17:00:48 +0100 |
commit | e110bbbc7a8dea47b9ed536fcd31dc21169c6bd6 (patch) | |
tree | 841cf9f4087ce61619fb698ba627dcaf69ab4b8a /api.lua | |
parent | 2f49d895ed9b9bea22e8937a4396560e2941d6de (diff) |
Add award unlock requirements
Fixes #52
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 |