-
-
Save irfan-dahir/9404a96d24c2c52ed2b496f835b4857e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Hook Management API | |
v0.0.0 - major.minor.patch | |
]] | |
Hook = {} | |
Hook.__index = Hook | |
HookCallable = {} | |
HookEvent = {} | |
--__addhook = addhook | |
function Hook:New() | |
local self = setmetatable({}, Hook) | |
return self | |
end | |
function Hook:Create(hookName, args) | |
loadstring('HookCallable.'..hookName..' = function('..args..') self.Event('..args..') end')(unpack(args:split(","))) | |
addhook(hookName, "HookCallable."..hookName) | |
end | |
-- thanks to http://www.unrealsoftware.de/forum_posts.php?post=419447&start=0#post419482 | |
function string:split(m) | |
local tbl = {} | |
for w in self:gmatch("[^" .. (m or "%s") .. "]+") do | |
table.insert(tbl, w) | |
end | |
return tbl | |
end |
Can be used like this now, thanks to http://www.unrealsoftware.de/forum_posts.php?post=419447&start=0#post419482
hook:Create('join', 'id')
hook:Create('die', 'victim, killer, wep, x, y, kObjID')
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using it: