From 96746aaf1e2c2c07dccafd9a6cebdbb15914ee98 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Fri, 29 Jul 2016 17:25:02 +0100 Subject: Add awards.increment_item_counter() and use it --- api.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'api.lua') diff --git a/api.lua b/api.lua index d7dbbcb..212e294 100644 --- a/api.lua +++ b/api.lua @@ -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 -- cgit v1.2.3