diff options
author | rubenwardy <rubenwardy@gmail.com> | 2016-08-01 20:27:12 +0100 |
---|---|---|
committer | rubenwardy <rubenwardy@gmail.com> | 2016-08-01 20:27:12 +0100 |
commit | b689dc8eaf799fe8f45724ace8bfa943436bc412 (patch) | |
tree | 90c606b5514e8915456a9bd9d2125ee629b692c4 /triggers.lua | |
parent | f5cf49af2ee073b470b7b28e72d95cffd8c4defd (diff) |
Add progress bar
Diffstat (limited to 'triggers.lua')
-rw-r--r-- | triggers.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/triggers.lua b/triggers.lua index 1a4e355..68a1856 100644 --- a/triggers.lua +++ b/triggers.lua @@ -21,6 +21,13 @@ awards.register_trigger("dig", function(def) target = def.trigger.target } table.insert(awards.on.dig, tmp) + def.getProgress = function(self, data) + local itemcount = awards.get_item_count(data, "count", tmp.node) or 0 + return { + perc = itemcount / tmp.target, + label = itemcount .. " / " .. tmp.target .. " dug" -- TODO: translation + } + end end) awards.register_trigger("place", function(def) @@ -30,6 +37,13 @@ awards.register_trigger("place", function(def) target = def.trigger.target } table.insert(awards.on.place, tmp) + def.getProgress = function(self, data) + local itemcount = awards.get_item_count(data, "place", tmp.node) or 0 + return { + perc = itemcount / tmp.target, + label = itemcount .. " / " .. tmp.target .. " placed" -- TODO: translation + } + end end) awards.register_trigger("death", function(def) @@ -38,6 +52,13 @@ awards.register_trigger("death", function(def) target = def.trigger.target } table.insert(awards.on.death, tmp) + def.getProgress = function(self, data) + local itemcount = data.deaths or 0 + return { + perc = itemcount / tmp.target, + label = itemcount .. " deaths, need " .. tmp.target -- TODO: translation + } + end end) awards.register_trigger("chat", function(def) @@ -46,6 +67,13 @@ awards.register_trigger("chat", function(def) target = def.trigger.target } table.insert(awards.on.chat, tmp) + def.getProgress = function(self, data) + local itemcount = data.chats or 0 + return { + perc = itemcount / tmp.target, + label = itemcount .. " / " .. tmp.target .. " line of chat" -- TODO: translation + } + end end) awards.register_trigger("join", function(def) @@ -54,6 +82,14 @@ awards.register_trigger("join", function(def) target = def.trigger.target } table.insert(awards.on.join, tmp) + + def.getProgress = function(self, data) + local itemcount = data.joins or 0 + return { + perc = itemcount / tmp.target, + label = itemcount .. " game joins, need " .. tmp.target -- TODO: translation + } + end end) awards.register_trigger("craft", function(def) @@ -63,6 +99,13 @@ awards.register_trigger("craft", function(def) target = def.trigger.target } table.insert(awards.on.craft, tmp) + def.getProgress = function(self, data) + local itemcount = awards.get_item_count(data, "craft", tmp.item) or 0 + return { + perc = itemcount / tmp.target, + label = itemcount .. " / " .. tmp.target .. " crafted" -- TODO: translation + } + end end) -- Backwards compatibility |