Divergent/mods/FDDA/gamedata/scripts/ea_callbacks.script

32 lines
728 B
Plaintext
Raw Normal View History

2024-03-17 20:18:03 -04:00
local intercepts = {}
function EA_RegisterScriptCallback(name,func_or_userdata)
if (func_or_userdata == nil) then
callstack()
end
if not intercepts[name] then
intercepts[name] = {}
end
if (intercepts[name]) then
intercepts[name][func_or_userdata] = true
end
end
function EA_UnregisterScriptCallback(name,func_or_userdata)
if (intercepts[name]) then
intercepts[name][func_or_userdata] = nil
end
end
function EA_SendScriptCallback(name,...)
if (intercepts[name]) then
for func_or_userdata,v in pairs(intercepts[name]) do
if (type(func_or_userdata) == "function") then
func_or_userdata(...)
elseif (func_or_userdata[name]) then
func_or_userdata[name](func_or_userdata,...)
end
end
end
end