From 38c504e938e169e0337591b7ffe13863ff21250d Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 15 Nov 2016 01:57:01 +0100 Subject: Add eat trigger, extend existing triggers, add 9 awards (#35) * Add eat trigger and 2 new awards * Add mushroom eating awards * Add support for counting any eat/dig/craft/place * Update readme * Add 4 builder awards * Update German locale * Update dependencies * Fix mistake in German translation * Revert removal of background --- api.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'api.lua') diff --git a/api.lua b/api.lua index 916441e..f53ee0d 100644 --- a/api.lua +++ b/api.lua @@ -115,6 +115,22 @@ function awards.get_item_count(data, field, itemname) end end +function awards.get_total_item_count(data, field) + local i = 0 + if data and field then + awards.assertPlayer(data) + awards.tbv(data, field) + for mod,_ in pairs(data[field]) do + awards.tbv(data[field], mod) + for item,_ in pairs(data[field][mod]) do + awards.tbv(data[field][mod], item, 0) + i = i + data[field][mod][item] + end + end + end + return i +end + function awards.register_on_unlock(func) table.insert(awards.on_unlock, func) end -- cgit v1.2.3