Add default_def for trigger prototype

This commit is contained in:
rubenwardy 2018-04-04 18:39:06 +01:00
parent cca278024d
commit f7956d97e2

@ -52,7 +52,9 @@ function awards.player_or_nil(name)
return awards.players[name] return awards.players[name]
end end
local function run_trigger_callbacks(self, player, data, table_func) local default_def = {}
function default_def:run_callbacks(player, data, table_func)
for i = 1, #self.on do for i = 1, #self.on do
local res = nil local res = nil
local entry = self.on[i] local entry = self.on[i]
@ -73,7 +75,9 @@ function awards.register_trigger(tname, tdef)
"Passing a callback to register_trigger is not supported in 3.0") "Passing a callback to register_trigger is not supported in 3.0")
tdef.name = tname tdef.name = tname
tdef.run_callbacks = run_trigger_callbacks for key, value in pairs(default_def) do
tdef[key] = value
end
if tdef.type == "counted" then if tdef.type == "counted" then
local old_reg = tdef.on_register local old_reg = tdef.on_register