now must reload
This commit is contained in:
parent
8421b61a82
commit
1b498be1d6
2 changed files with 16 additions and 4 deletions
|
@ -17,6 +17,14 @@ end
|
||||||
function events:on(n,f) self:_add('on', n,f) end
|
function events:on(n,f) self:_add('on', n,f) end
|
||||||
function events:once(n,f) self:_add('once', n,f) end
|
function events:once(n,f) self:_add('once', n,f) end
|
||||||
|
|
||||||
|
function events:off(f)
|
||||||
|
for k, v in pairs(self._ev_) do
|
||||||
|
if v.fn == f then
|
||||||
|
table.remove(self._ev_, k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function events:_ev(t, i, name, ...)
|
function events:_ev(t, i, name, ...)
|
||||||
local v = t[i]
|
local v = t[i]
|
||||||
if v.name == name then
|
if v.name == name then
|
||||||
|
|
|
@ -9,9 +9,13 @@ return {
|
||||||
local path = 'src.'..cat..'.'..sub
|
local path = 'src.'..cat..'.'..sub
|
||||||
package.loaded[path] = nil
|
package.loaded[path] = nil
|
||||||
local err, m = pcall(require, path)
|
local err, m = pcall(require, path)
|
||||||
C.api:reply(msg, ('Reloaded. %s (%s)'):format(
|
|
||||||
not err and 'Error:' or 'Result:',
|
if not err then return C.api:reply(msg, 'Reload failed. ' .. m)
|
||||||
m
|
elseif cat == 'events' then C.api:off(m); C.api:on(sub, m)
|
||||||
))
|
elseif cat == 'cmds' then C.cmds[sub] = m
|
||||||
|
elseif cat == 'parts' then m(C)
|
||||||
|
end
|
||||||
|
|
||||||
|
C.api:reply(msg, 'Reloaded. ' .. tostring(m))
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue