diff options
author | rubenwardy <rubenwardy@gmail.com> | 2016-07-29 17:14:57 +0100 |
---|---|---|
committer | rubenwardy <rubenwardy@gmail.com> | 2016-07-29 17:15:52 +0100 |
commit | f430b4eb6852afed312357a26a1d7ff96da7c65e (patch) | |
tree | 629557722d4edfcaf00e582d4fd7647b4fcdf972 /api.lua | |
parent | dee1880fd3e123225491f8e2725fab2cb4b01738 (diff) |
Move unrelated things from trigger.lua
Diffstat (limited to 'api.lua')
-rw-r--r-- | api.lua | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -61,6 +61,22 @@ function awards.register_trigger(name, func) end end +function awards.run_trigger_callbacks(player, data, trigger, table_func) + for i = 1, #awards.on[trigger] do + local res = nil + local entry = awards.on[trigger][i] + if type(entry) == "function" then + res = entry(player, data) + elseif type(entry) == "table" and entry.award then + res = table_func(entry) + end + + if res then + awards.unlock(player:get_player_name(), res) + end + end +end + function awards.register_on_unlock(func) table.insert(awards.on_unlock, func) end @@ -367,3 +383,12 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end) awards.init() + +minetest.register_on_newplayer(function(player) + local playern = player:get_player_name() + awards.assertPlayer(playern) +end) + +minetest.register_on_shutdown(function() + awards.save() +end) |