diff --git a/bc.lua b/bc.lua index c05b70b31c91..d8d833cd3d41 100644 --- a/bc.lua +++ b/bc.lua @@ -129,7 +129,12 @@ function BaseControl:register(name, value) error("can't register \""..name.."\" after finalizing") end - if type(value) == "function" then + if type(name) == "table" then + -- Batch register + for name, value in pairs(name) do + self:register(name, value) + end + elseif type(value) == "function" then if self.local_verbs[name] ~= nil then error("\""..name.."\" already registered") else diff --git a/tests/local.lua b/tests/local.lua index 22e399e7ec01..eaa9d7ee6e08 100644 --- a/tests/local.lua +++ b/tests/local.lua @@ -51,6 +51,20 @@ function test_register() end) end +function test_register_batch() + local bc = BaseControl:new() + bc:register{ + rb1=1234, + rb2=4321, + rb3v=function() end, + } + bc:finalize() + + assert_true(bc:has_noun("rb1")) + assert_true(bc:has_noun("rb2")) + assert_true(bc:has_verb("rb3v")) +end + function test_available() local bc = BaseControl:new() bc:register("available1", 1234)