There is another solution. You can store all callbacks in a hooks table, and register all callbacks from this table, for example:
Code:
hooks={}
function hooks.tick(e,d) -- Will be registered as HOOK_TICK hook.
-- Do something cool
return ... -- Return something cool
end
function Initialize(Plugin)
Plugin:SetName("SomeCoolPlugin")
Plugin:SetVersion(1)
if hooks then
for k,v in pairs(hooks) do
cPluginManager.AddHook(cPluginManager["HOOK_"..string.upper(k)], v)
end
end
PLUGIN = Plugin -- NOTE: only needed if you want OnDisable() to use GetName() or something like that
if commands then
for k,v in pairs(commands) do
cPluginManager.BindCommand(unpack(v))
end
end
LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
return true
end
function OnDisable()
LOG(PLUGIN:GetName() .. " is shutting down...")
end