awards.register_trigger

This commit is contained in:
rubenwardy 2015-06-10 18:39:22 +01:00
parent 85efc67049
commit 87c04be9ea
5 changed files with 175 additions and 163 deletions

114
api.lua

@ -21,6 +21,8 @@ end
function awards.init() function awards.init()
awards.players = awards.load() awards.players = awards.load()
awards.def = {} awards.def = {}
awards.trigger_types = {}
awards.on = {}
end end
function awards.load() function awards.load()
@ -36,100 +38,45 @@ end
awards.init() awards.init()
-- Load files function awards.register_trigger(name, func)
dofile(minetest.get_modpath("awards").."/helpers.lua") awards.trigger_types[name] = func
dofile(minetest.get_modpath("awards").."/triggers.lua") awards.on[name] = {}
awards['register_on_'..name] = function(func)
table.insert(awards.on[name], func)
end
end
-- API Functions -- API Functions
function awards._additional_triggers(name, data_table) function awards._additional_triggers(name, def)
-- Depreciated! -- Depreciated!
end end
function awards.register_achievement(name,data_table)
-- see if a trigger is defined in the achievement definition function awards.register_achievement(name, def)
if data_table.trigger and data_table.trigger.type then -- Add Triggers
if data_table.trigger.type == "dig" then if def.trigger and def.trigger.type then
local tmp = { local func = awards.trigger_types[def.trigger.type]
award = name,
node = data_table.trigger.node, if func then
target = data_table.trigger.target, func(name, def)
}
table.insert(awards.onDig,tmp)
elseif data_table.trigger.type == "place" then
local tmp = {
award = name,
node = data_table.trigger.node,
target = data_table.trigger.target,
}
table.insert(awards.onPlace,tmp)
elseif data_table.trigger.type == "craft" then
local tmp = {
award = name,
item = data_table.trigger.item,
target = data_table.trigger.target,
}
table.insert(awards.onCraft,tmp)
elseif data_table.trigger.type == "death" then
local tmp = {
award = name,
target = data_table.trigger.target,
}
table.insert(awards.onDeath,tmp)
elseif data_table.trigger.type == "chat" then
local tmp = {
award = name,
target = data_table.trigger.target,
}
table.insert(awards.onChat,tmp)
elseif data_table.trigger.type == "join" then
local tmp = {
award = name,
target = data_table.trigger.target,
}
table.insert(awards.onJoin,tmp)
else else
awards._additional_triggers(name, data_table) awards._additional_triggers(name, def)
end end
end end
-- check icon, background and custom_announce data -- check icon, background and custom_announce data
if data_table.icon == nil or data_table.icon == "" then if not def.icon or def.icon == "" then
data_table.icon = "unknown.png" def.icon = "unknown.png"
end end
if data_table.background == nil or data_table.background == "" then if not def.background or def.background == "" then
data_table.background = "bg_default.png" def.background = "bg_default.png"
end end
if data_table.custom_announce == nil or data_table.custom_announce == "" then if not def.custom_announce or def.custom_announce == "" then
data_table.custom_announce = "Achievement Unlocked:" def.custom_announce = "Achievement Unlocked:"
end end
-- add the achievement to the definition table -- add the achievement to the definition table
data_table.name = name def.name = name
awards.def[name] = data_table awards.def[name] = def
end
-- run a function when a node is dug
function awards.register_onDig(func)
table.insert(awards.onDig,func)
end
-- run a function when a node is placed
function awards.register_onPlace(func)
table.insert(awards.onPlace,func)
end
-- run a function when a player dies
function awards.register_onDeath(func)
table.insert(awards.onDeath,func)
end
-- run a function when a player chats
function awards.register_onChat(func)
table.insert(awards.onChat,func)
end
-- run a function when a player joins
function awards.register_onJoin(func)
table.insert(awards.onJoin,func)
end end
-- run a function when an item is crafted -- run a function when an item is crafted
@ -390,3 +337,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
return true return true
end) end)
-- Load files
dofile(minetest.get_modpath("awards").."/helpers.lua")
dofile(minetest.get_modpath("awards").."/triggers.lua")

@ -35,3 +35,18 @@ minetest.register_chatcommand("awd", {
end end
end end
}) })
minetest.register_chatcommand("awpl", {
privs = {
server = true
},
description = "awpl: Get the statistics for the player given",
func = function(name, param)
if not param or param == "" then
param = name
end
minetest.chat_send_player(name, param)
local player = awards.player(param)
minetest.chat_send_player(name, dump(player))
end
})

@ -92,7 +92,7 @@ awards.register_achievement("award_obsessed_with_obsidian",{
}) })
-- On the way -- On the way
awards.register_achievement("award_on_the_way",{ awards.register_achievement("award_on_the_way", {
title = S("On The Way"), title = S("On The Way"),
description = S("Place 100 rails."), description = S("Place 100 rails."),
icon = "novicebuilder.png", icon = "novicebuilder.png",
@ -104,19 +104,19 @@ awards.register_achievement("award_on_the_way",{
}) })
-- Lumberjack -- Lumberjack
awards.register_achievement("award_lumberjack",{ awards.register_achievement("award_lumberjack", {
title = S("Lumberjack"), title = S("Lumberjack"),
description = S("Dig 100 tree blocks."), description = S("Dig 100 tree blocks."),
icon = "default_tree.png", icon = "default_tree.png",
trigger = { trigger = {
type = "dig", type = "dig",
node = "default:tree", node = "default:tree",
target = 100 target = 1
} }
}) })
-- Semi-pro Lumberjack -- Semi-pro Lumberjack
awards.register_achievement("award_lumberjack_semipro",{ awards.register_achievement("award_lumberjack_semipro", {
title = S("Semi-pro Lumberjack"), title = S("Semi-pro Lumberjack"),
description = S("Dig 1,000 tree blocks."), description = S("Dig 1,000 tree blocks."),
icon = "default_tree.png", icon = "default_tree.png",
@ -128,7 +128,7 @@ awards.register_achievement("award_lumberjack_semipro",{
}) })
-- Professional Lumberjack -- Professional Lumberjack
awards.register_achievement("award_lumberjack_professional",{ awards.register_achievement("award_lumberjack_professional", {
title = S("Professional Lumberjack"), title = S("Professional Lumberjack"),
description = S("Dig 10,000 tree blocks."), description = S("Dig 10,000 tree blocks."),
icon = "default_tree.png", icon = "default_tree.png",
@ -140,7 +140,7 @@ awards.register_achievement("award_lumberjack_professional",{
}) })
-- L33T Lumberjack -- L33T Lumberjack
awards.register_achievement("award_lumberjack_leet",{ awards.register_achievement("award_lumberjack_leet", {
title = S("L33T Lumberjack"), title = S("L33T Lumberjack"),
description = S("Dig 100,000 tree blocks."), description = S("Dig 100,000 tree blocks."),
icon = "default_tree.png", icon = "default_tree.png",
@ -152,7 +152,7 @@ awards.register_achievement("award_lumberjack_leet",{
}) })
-- Junglebaby -- Junglebaby
awards.register_achievement("award_junglebaby",{ awards.register_achievement("award_junglebaby", {
title = S("Junglebaby"), title = S("Junglebaby"),
description = S("Dig 100 jungle tree blocks."), description = S("Dig 100 jungle tree blocks."),
icon = "default_jungletree.png", icon = "default_jungletree.png",
@ -164,7 +164,7 @@ awards.register_achievement("award_junglebaby",{
}) })
-- Jungleman -- Jungleman
awards.register_achievement("award_jungleman",{ awards.register_achievement("award_jungleman", {
title = S("Jungleman"), title = S("Jungleman"),
description = S("Dig 1,000 jungle tree blocks."), description = S("Dig 1,000 jungle tree blocks."),
icon = "default_jungletree.png", icon = "default_jungletree.png",
@ -176,7 +176,7 @@ awards.register_achievement("award_jungleman",{
}) })
-- Found some Mese! -- Found some Mese!
awards.register_achievement("award_mesefind",{ awards.register_achievement("award_mesefind", {
title = S("First Mese Find"), title = S("First Mese Find"),
description = S("Find some Mese."), description = S("Find some Mese."),
icon = "default_mese_block.png", icon = "default_mese_block.png",
@ -189,7 +189,7 @@ awards.register_achievement("award_mesefind",{
}) })
-- You're a copper -- You're a copper
awards.register_achievement("award_youre_a_copper",{ awards.register_achievement("award_youre_a_copper", {
title = S("You're a copper"), title = S("You're a copper"),
description = S("Dig 1,000 copper ores."), description = S("Dig 1,000 copper ores."),
icon = "miniminer.png", icon = "miniminer.png",
@ -202,7 +202,7 @@ awards.register_achievement("award_youre_a_copper",{
}) })
-- You're winner -- You're winner
awards.register_achievement("award_youre_winner",{ awards.register_achievement("award_youre_winner", {
title = S("YOU'RE A WINNER!"), title = S("YOU'RE A WINNER!"),
description = S("Dig 1 mossy cobblestone."), description = S("Dig 1 mossy cobblestone."),
icon = "miniminer.png", icon = "miniminer.png",
@ -216,7 +216,7 @@ awards.register_achievement("award_youre_winner",{
}) })
-- Found a Nyan cat! -- Found a Nyan cat!
awards.register_achievement("award_nyanfind",{ awards.register_achievement("award_nyanfind", {
title = S("OMG, Nyan Cat!"), title = S("OMG, Nyan Cat!"),
description = S("Find a nyan cat."), description = S("Find a nyan cat."),
icon = "default_nc_rb.png", icon = "default_nc_rb.png",
@ -228,7 +228,7 @@ awards.register_achievement("award_nyanfind",{
}) })
-- Mini Miner -- Mini Miner
awards.register_achievement("award_mine2",{ awards.register_achievement("award_mine2", {
title = S("Mini Miner"), title = S("Mini Miner"),
description = S("Dig 100 stone blocks."), description = S("Dig 100 stone blocks."),
icon = "miniminer.png", icon = "miniminer.png",
@ -241,7 +241,7 @@ awards.register_achievement("award_mine2",{
}) })
-- Hardened Miner -- Hardened Miner
awards.register_achievement("award_mine3",{ awards.register_achievement("award_mine3", {
title = S("Hardened Miner"), title = S("Hardened Miner"),
description = S("Dig 1,000 stone blocks"), description = S("Dig 1,000 stone blocks"),
icon = "miniminer.png", icon = "miniminer.png",
@ -254,7 +254,7 @@ awards.register_achievement("award_mine3",{
}) })
-- Master Miner -- Master Miner
awards.register_achievement("award_mine4",{ awards.register_achievement("award_mine4", {
title = S("Master Miner"), title = S("Master Miner"),
description = S("Dig 10,000 stone blocks."), description = S("Dig 10,000 stone blocks."),
icon = "miniminer.png", icon = "miniminer.png",
@ -267,7 +267,7 @@ awards.register_achievement("award_mine4",{
}) })
-- Marchand de sable -- Marchand de sable
awards.register_achievement("award_marchand_de_sable",{ awards.register_achievement("award_marchand_de_sable", {
title = S("Marchand De Sable"), title = S("Marchand De Sable"),
description = S("Dig 1,000 sand."), description = S("Dig 1,000 sand."),
background = "bg_mining.png", background = "bg_mining.png",
@ -279,7 +279,7 @@ awards.register_achievement("award_marchand_de_sable",{
}) })
-- Join -- Join
awards.register_achievement("award_join2",{ awards.register_achievement("award_join2", {
title = S("Frequent Visitor"), title = S("Frequent Visitor"),
description = S("Connect to the server 50 times."), description = S("Connect to the server 50 times."),
trigger = { trigger = {
@ -290,7 +290,7 @@ awards.register_achievement("award_join2",{
}) })
-- Dying Spree -- Dying Spree
awards.register_achievement("award_dying_spree",{ awards.register_achievement("award_dying_spree", {
title = S("Dying Spree"), title = S("Dying Spree"),
description = S("Die 5 times."), description = S("Die 5 times."),
trigger = { trigger = {
@ -300,7 +300,7 @@ awards.register_achievement("award_dying_spree",{
}) })
-- Bot-like -- Bot-like
awards.register_achievement("award_bot_like",{ awards.register_achievement("award_bot_like", {
title = S("Bot-like"), title = S("Bot-like"),
description = S("Die 10 times."), description = S("Die 10 times."),
trigger = { trigger = {
@ -310,7 +310,7 @@ awards.register_achievement("award_bot_like",{
}) })
-- You Suck! -- You Suck!
awards.register_achievement("award_you_suck",{ awards.register_achievement("award_you_suck", {
title = S("You Suck!"), title = S("You Suck!"),
description = S("Die 100 times."), description = S("Die 100 times."),
trigger = { trigger = {
@ -321,7 +321,7 @@ awards.register_achievement("award_you_suck",{
}) })
-- Burned to death -- Burned to death
awards.register_achievement("award_burn",{ awards.register_achievement("award_burn", {
title = S("You're a witch!"), title = S("You're a witch!"),
description = S("Burn to death in a fire.") description = S("Burn to death in a fire.")
}) })
@ -334,7 +334,7 @@ awards.register_onDeath(function(player,data)
end) end)
-- Died in flowing lava -- Died in flowing lava
awards.register_achievement("award_in_the_flow",{ awards.register_achievement("award_in_the_flow", {
title = S("In the Flow"), title = S("In the Flow"),
description = S("Die in flowing lava.") description = S("Die in flowing lava.")
}) })
@ -347,11 +347,11 @@ awards.register_onDeath(function(player,data)
end) end)
-- Die near diamond ore -- Die near diamond ore
awards.register_achievement("award_this_is_sad",{ awards.register_achievement("award_this_is_sad", {
title = S("This is Sad"), title = S("This is Sad"),
description = S("Die near diamond ore.") description = S("Die near diamond ore.")
}) })
awards.register_onDeath(function(player,data) awards.register_on_death(function(player,data)
local pos = player:getpos() local pos = player:getpos()
if pos and minetest.find_node_near(pos, 5, "default:stone_with_diamond") ~= nil then if pos and minetest.find_node_near(pos, 5, "default:stone_with_diamond") ~= nil then
return "award_this_is_sad" return "award_this_is_sad"
@ -360,11 +360,11 @@ awards.register_onDeath(function(player,data)
end) end)
-- Die near diamond ore -- Die near diamond ore
awards.register_achievement("award_the_stack",{ awards.register_achievement("award_the_stack", {
title = S("The Stack"), title = S("The Stack"),
description = S("Die near bones.") description = S("Die near bones.")
}) })
awards.register_onDeath(function(player,data) awards.register_on_death(function(player,data)
local pos = player:getpos() local pos = player:getpos()
if pos and minetest.find_node_near(pos, 5, "bones:bones") ~= nil then if pos and minetest.find_node_near(pos, 5, "bones:bones") ~= nil then
return "award_the_stack" return "award_the_stack"

@ -1,5 +1,4 @@
Awards # Awards
------
by Andrew "Rubenwardy" Ward, LGPL 2.1 or later. by Andrew "Rubenwardy" Ward, LGPL 2.1 or later.
@ -9,40 +8,45 @@ Majority of awards are back ported from Calinou's
old fork in Carbone, under same license. old fork in Carbone, under same license.
Code Reference # Basic API
--------------
The API * awards.register_achievement(name, def)
=======
* awards.register_achievement(name,data_table)
* name * name
* desciption * desciption
* sound [optional] * sound [optional]
* image [optional] * image [optional] - texture name, eg: award_one.png
* background [optional] - texture name, eg: award_one.png
* trigger [optional] [table] * trigger [optional] [table]
* type - "dig", "place", "craft", "death", "chat" or "join" * type - "dig", "place", "craft", "death", "chat" or "join"
* (for dig/place type) node - the nodes name * (for dig/place type) node - the nodes name
* (for craft type) item - the items name * (for craft type) item - the items name
* (for all types) target - how many to dig / place * (for all types) target - how many to dig / place
* See Triggers
* secret [optional] - if true, then player needs to unlock to find out what it is. * secret [optional] - if true, then player needs to unlock to find out what it is.
* awards.register_trigger(name, func(awardname, def))
* Note: awards.on[name] is automatically created for triggers
* awards.give_achievement(name,award) * awards.give_achievement(name,award)
* -- gives an award to a player * -- gives an award to a player
* awards.register_onDig(func(player,data))
# Included in the Mod
## Triggers
* awards.register_on_dig(func(player, data))
* -- return award name or null * -- return award name or null
* awards.register_onPlace(func(player,data)) * awards.register_on_place(func(player, data))
* -- return award name or null * -- return award name or null
* awards.register_onDeath(func(player,data)) * awards.register_on_death(func(player, data))
* -- return award name or null * -- return award name or null
* awards.register_onChat(func(player,data)) * awards.register_on_chat(func(player, data))
* -- return award name or null * -- return award name or null
* awards.register_onJoin(func(player,data)) * awards.register_on_join(func(player, data))
* -- return award name or null * -- return award name or null
* awards.register_onCraft(func(player,data)) * awards.register_onCraft(func(player,data))
* -- return award name or null * -- return award name or null
Player Data # Player Data
===========
A list of data referenced/hashed by the player's name. A list of data referenced/hashed by the player's name.
* player name * player name

@ -4,13 +4,54 @@
-- this is the trigger handler file for the awards mod -- this is the trigger handler file for the awards mod
------------------------------------------------------- -------------------------------------------------------
-- Function and table holders for Triggers awards.register_trigger("dig", function(name, def)
awards.onDig = {} local tmp = {
awards.onPlace = {} award = name,
awards.onCraft = {} node = def.trigger.node,
awards.onChat = {} target = def.trigger.target
awards.onDeath = {} }
awards.onJoin = {} table.insert(awards.on.dig, tmp)
end)
awards.register_trigger("place", function(name, def)
local tmp = {
award = name,
node = def.trigger.node,
target = def.trigger.target
}
table.insert(awards.on.place, tmp)
end)
awards.register_trigger("death", function(name, def)
local tmp = {
award = name,
target = def.trigger.target
}
table.insert(awards.on.death, tmp)
end)
awards.register_trigger("chat", function(name, def)
local tmp = {
award = name,
target = def.trigger.target
}
table.insert(awards.on.chat, tmp)
end)
awards.register_trigger("join", function(name, def)
local tmp = {
award = name,
target = def.trigger.target
}
table.insert(awards.on.join, tmp)
end)
-- Backwards compatibility
awards.register_onDig = awards.register_on_dig
awards.register_onPlace = awards.register_on_place
awards.register_onDeath = awards.register_on_death
awards.register_onChat = awards.register_on_chat
awards.register_onJoin = awards.register_on_join
-- Trigger Handles -- Trigger Handles
minetest.register_on_dignode(function(pos, oldnode, digger) minetest.register_on_dignode(function(pos, oldnode, digger)
@ -19,7 +60,6 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
end end
local nodedug = string.split(oldnode.name, ":") local nodedug = string.split(oldnode.name, ":")
if #nodedug ~= 2 then if #nodedug ~= 2 then
--minetest.log("error","Awards mod: "..oldnode.name.." is in wrong format!")
return return
end end
local mod = nodedug[1] local mod = nodedug[1]
@ -37,27 +77,27 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
awards.players[playern].count[mod][item]=awards.players[playern].count[mod][item] + 1 awards.players[playern].count[mod][item]=awards.players[playern].count[mod][item] + 1
-- Run callbacks and triggers -- Run callbacks and triggers
local player=digger local player = digger
local data=awards.players[playern] local data = awards.players[playern]
for i=1,# awards.onDig do for i=1, #awards.on.dig do
local res = nil local res = nil
if type(awards.onDig[i]) == "function" then if type(awards.on.dig[i]) == "function" then
-- Run trigger callback -- Run trigger callback
res = awards.onDig[i](player,data) res = awards.on.dig[i](player,data)
elseif type(awards.onDig[i]) == "table" then elseif type(awards.on.dig[i]) == "table" then
-- Handle table trigger -- Handle table trigger
if not awards.onDig[i].node or not awards.onDig[i].target or not awards.onDig[i].award then if not awards.on.dig[i].node or not awards.on.dig[i].target or not awards.on.dig[i].award then
-- table running failed! -- table running failed!
print("[ERROR] awards - onDig trigger "..i.." is invalid!") print("[ERROR] awards - on.dig trigger "..i.." is invalid!")
else else
-- run the table -- run the table
local tnodedug = string.split(awards.onDig[i].node, ":") local tnodedug = string.split(awards.on.dig[i].node, ":")
local tmod=tnodedug[1] local tmod=tnodedug[1]
local titem=tnodedug[2] local titem=tnodedug[2]
if tmod==nil or titem==nil or not data.count[tmod] or not data.count[tmod][titem] then if tmod==nil or titem==nil or not data.count[tmod] or not data.count[tmod][titem] then
-- table running failed! -- table running failed!
elseif data.count[tmod][titem] > awards.onDig[i].target-1 then elseif data.count[tmod][titem] > awards.on.dig[i].target-1 then
res=awards.onDig[i].award res=awards.on.dig[i].award
end end
end end
end end
@ -68,13 +108,12 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
end end
end) end)
minetest.register_on_placenode(function(pos,node,digger) minetest.register_on_placenode(function(pos, node, digger)
if not digger or not pos or not node or not digger:get_player_name() or digger:get_player_name()=="" then if not digger or not pos or not node or not digger:get_player_name() or digger:get_player_name()=="" then
return return
end end
local nodedug = string.split(node.name, ":") local nodedug = string.split(node.name, ":")
if #nodedug ~= 2 then if #nodedug ~= 2 then
--minetest.log("error","Awards mod: "..node.name.." is in wrong format!")
return return
end end
local mod=nodedug[1] local mod=nodedug[1]
@ -95,24 +134,24 @@ minetest.register_on_placenode(function(pos,node,digger)
-- Run callbacks and triggers -- Run callbacks and triggers
local player = digger local player = digger
local data = awards.players[playern] local data = awards.players[playern]
for i=1,# awards.onPlace do for i=1,# awards.on.place do
local res = nil local res = nil
if type(awards.onPlace[i]) == "function" then if type(awards.on.place[i]) == "function" then
-- Run trigger callback -- Run trigger callback
res = awards.onPlace[i](player,data) res = awards.on.place[i](player,data)
elseif type(awards.onPlace[i]) == "table" then elseif type(awards.on.place[i]) == "table" then
-- Handle table trigger -- Handle table trigger
if not awards.onPlace[i].node or not awards.onPlace[i].target or not awards.onPlace[i].award then if not awards.on.place[i].node or not awards.on.place[i].target or not awards.on.place[i].award then
print("[ERROR] awards - onPlace trigger "..i.." is invalid!") print("[ERROR] awards - on.place trigger "..i.." is invalid!")
else else
-- run the table -- run the table
local tnodedug = string.split(awards.onPlace[i].node, ":") local tnodedug = string.split(awards.on.place[i].node, ":")
local tmod = tnodedug[1] local tmod = tnodedug[1]
local titem = tnodedug[2] local titem = tnodedug[2]
if tmod==nil or titem==nil or not data.place[tmod] or not data.place[tmod][titem] then if tmod==nil or titem==nil or not data.place[tmod] or not data.place[tmod][titem] then
-- table running failed! -- table running failed!
elseif data.place[tmod][titem] > awards.onPlace[i].target-1 then elseif data.place[tmod][titem] > awards.on.place[i].target-1 then
res = awards.onPlace[i].award res = awards.on.place[i].award
end end
end end
end end
@ -192,7 +231,7 @@ minetest.register_on_dieplayer(function(player)
data.deaths = data.deaths + 1 data.deaths = data.deaths + 1
-- Run callbacks and triggers -- Run callbacks and triggers
for _,trigger in pairs(awards.onDeath) do for _,trigger in pairs(awards.on.death) do
local res = nil local res = nil
if type(trigger) == "function" then if type(trigger) == "function" then
res = trigger(player,data) res = trigger(player,data)
@ -224,7 +263,7 @@ minetest.register_on_joinplayer(function(player)
data.joins = data.joins + 1 data.joins = data.joins + 1
-- Run callbacks and triggers -- Run callbacks and triggers
for _,trigger in pairs(awards.onJoin) do for _, trigger in pairs(awards.on.join) do
local res = nil local res = nil
if type(trigger) == "function" then if type(trigger) == "function" then
res = trigger(player,data) res = trigger(player,data)
@ -257,7 +296,7 @@ minetest.register_on_chat_message(function(name, message)
data.chats = data.chats + 1 data.chats = data.chats + 1
-- Run callbacks and triggers -- Run callbacks and triggers
for _,trigger in pairs(awards.onChat) do for _,trigger in pairs(awards.on.chat) do
local res = nil local res = nil
if type(trigger) == "function" then if type(trigger) == "function" then
res = trigger(player,data) res = trigger(player,data)