summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubenwardy <rubenwardy@gmail.com>2014-09-26 20:55:44 +0100
committerrubenwardy <rubenwardy@gmail.com>2014-09-26 20:55:44 +0100
commite8f119bf3136608e94c5f9e594bd2683e0077c2e (patch)
treea775aa0e087c686ab71a93904205292d75335d31
parenta806f177b158acedcfd4efce80fb02a783e1385a (diff)
Add support for prizes
-rw-r--r--api.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/api.lua b/api.lua
index 66dc53a..e201cb5 100644
--- a/api.lua
+++ b/api.lua
@@ -206,6 +206,21 @@ function awards.give_achievement(name, award)
-- Set award flag
data.unlocked[award]=award
+ -- Give Prizes
+ if awards.def[award] and awards.def[award].prizes then
+ for i = 1, #awards.def[award].prizes do
+ local itemstack = ItemStack(awards.def[award].prizes[i])
+ if itemstack:is_empty() or not itemstack:is_known() then
+ return
+ end
+ local receiverref = core.get_player_by_name(name)
+ if receiverref == nil then
+ return
+ end
+ receiverref:get_inventory():add_item("main", itemstack)
+ end
+ end
+
-- Get data from definition tables
local title = award
local desc = ""