From c7bf8efbc0d52742bfb44f3081a182308a348589 Mon Sep 17 00:00:00 2001 From: Saif Date: Sun, 23 Aug 2015 14:04:13 +0500 Subject: [PATCH 1/2] Handler names to allow types other than strings. --- AIO_Client/AIO.lua | 6 +++--- AIO_Server/AIO.lua | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/AIO_Client/AIO.lua b/AIO_Client/AIO.lua index 1fdeecd..05cc6f2 100644 --- a/AIO_Client/AIO.lua +++ b/AIO_Client/AIO.lua @@ -796,7 +796,7 @@ end -- is received, the handlertable["HandlerName"] will be executed with player and additional params passed to the block. -- Returns the passed table function AIO.AddHandlers(name, handlertable) - assert(type(name) == 'string', "#1 string expected") + assert(name ~= nil, "#1 expected not nil") assert(type(handlertable) == 'table', "#2 a table expected") for k,v in pairs(handlertable) do @@ -833,7 +833,7 @@ if AIO_SERVER then -- A shorthand for sending a message for a handler. function AIO.Handle(player, name, handlername, ...) assert(type(player) == 'userdata', "#1 player expected") - assert(type(name) == 'string', "#2 string expected") + assert(name ~= nil, "#2 expected not nil") return AIO.Msg():Add(name, handlername, ...):Send(player) end @@ -947,7 +947,7 @@ else -- A shorthand for sending a message for a handler. function AIO.Handle(name, handlername, ...) - assert(type(name) == 'string', "#1 string expected") + assert(name ~= nil, "#1 expected not nil") return AIO.Msg():Add(name, handlername, ...):Send() end diff --git a/AIO_Server/AIO.lua b/AIO_Server/AIO.lua index 1fdeecd..05cc6f2 100644 --- a/AIO_Server/AIO.lua +++ b/AIO_Server/AIO.lua @@ -796,7 +796,7 @@ end -- is received, the handlertable["HandlerName"] will be executed with player and additional params passed to the block. -- Returns the passed table function AIO.AddHandlers(name, handlertable) - assert(type(name) == 'string', "#1 string expected") + assert(name ~= nil, "#1 expected not nil") assert(type(handlertable) == 'table', "#2 a table expected") for k,v in pairs(handlertable) do @@ -833,7 +833,7 @@ if AIO_SERVER then -- A shorthand for sending a message for a handler. function AIO.Handle(player, name, handlername, ...) assert(type(player) == 'userdata', "#1 player expected") - assert(type(name) == 'string', "#2 string expected") + assert(name ~= nil, "#2 expected not nil") return AIO.Msg():Add(name, handlername, ...):Send(player) end @@ -947,7 +947,7 @@ else -- A shorthand for sending a message for a handler. function AIO.Handle(name, handlername, ...) - assert(type(name) == 'string', "#1 string expected") + assert(name ~= nil, "#1 expected not nil") return AIO.Msg():Add(name, handlername, ...):Send() end From 2b734d9b07e500fd08da480d9f84632116929a64 Mon Sep 17 00:00:00 2001 From: Saif Date: Sun, 23 Aug 2015 18:18:06 +0500 Subject: [PATCH 2/2] Changed AIO.RegisterEvent assertion --- AIO_Client/AIO.lua | 2 +- AIO_Server/AIO.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AIO_Client/AIO.lua b/AIO_Client/AIO.lua index 05cc6f2..2e9a651 100644 --- a/AIO_Client/AIO.lua +++ b/AIO_Client/AIO.lua @@ -784,7 +784,7 @@ end -- All parameters the client sends will be passed to func when called -- Only one function can be a handler for one name (subject for change) function AIO.RegisterEvent(name, func) - assert(type(name) == "string", "name of the registered event string expected") + assert(name ~= nil, "name of the registered event expected not nil") assert(type(func) == "function", "callback function must be a function") assert(not AIO_BLOCKHANDLES[name], "an event is already registered for the name: "..name) AIO_BLOCKHANDLES[name] = func diff --git a/AIO_Server/AIO.lua b/AIO_Server/AIO.lua index 05cc6f2..2e9a651 100644 --- a/AIO_Server/AIO.lua +++ b/AIO_Server/AIO.lua @@ -784,7 +784,7 @@ end -- All parameters the client sends will be passed to func when called -- Only one function can be a handler for one name (subject for change) function AIO.RegisterEvent(name, func) - assert(type(name) == "string", "name of the registered event string expected") + assert(name ~= nil, "name of the registered event expected not nil") assert(type(func) == "function", "callback function must be a function") assert(not AIO_BLOCKHANDLES[name], "an event is already registered for the name: "..name) AIO_BLOCKHANDLES[name] = func