mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 15:01:49 +00:00
add prefix check to events.on
This commit is contained in:
parent
31d2dde534
commit
60ed10c0a1
1 changed files with 7 additions and 0 deletions
|
|
@ -2,7 +2,14 @@ local events = {
|
||||||
handlers = {}
|
handlers = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local __parse_path = parse_path
|
||||||
|
local __pack_is_installed = pack.is_installed
|
||||||
|
|
||||||
function events.on(event, func)
|
function events.on(event, func)
|
||||||
|
local prefix = __parse_path(event)
|
||||||
|
if prefix ~= "core" and not __pack_is_installed(prefix) then
|
||||||
|
error("pack prefix required")
|
||||||
|
end
|
||||||
if events.handlers[event] == nil then
|
if events.handlers[event] == nil then
|
||||||
events.handlers[event] = {}
|
events.handlers[event] = {}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue