diff options
author | rubenwardy <rubenwardy@gmail.com> | 2016-07-29 17:25:02 +0100 |
---|---|---|
committer | rubenwardy <rubenwardy@gmail.com> | 2016-07-29 17:25:02 +0100 |
commit | 96746aaf1e2c2c07dccafd9a6cebdbb15914ee98 (patch) | |
tree | 4e65b11a539d8ce28ba1f22571d47c5400c8bdab /api.lua | |
parent | f430b4eb6852afed312357a26a1d7ff96da7c65e (diff) |
Add awards.increment_item_counter() and use it
Diffstat (limited to 'api.lua')
-rw-r--r-- | api.lua | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -77,6 +77,27 @@ function awards.run_trigger_callbacks(player, data, trigger, table_func) end end +function awards.increment_item_counter(data, field, itemname) + local name_split = string.split(itemname, ":") + if #name_split ~= 2 then + return false + end + local mod = name_split[1] + local item = name_split[2] + + if data and field and mod and item then + awards.assertPlayer(data) + awards.tbv(data, field) + awards.tbv(data[field], mod) + awards.tbv(data[field][mod], item, 0) + + data[field][mod][item] = data[field][mod][item] + 1 + return true + else + return false + end +end + function awards.register_on_unlock(func) table.insert(awards.on_unlock, func) end |