From f9a14ecaeb4415a6def75216ce250d2c197e90ef Mon Sep 17 00:00:00 2001 From: Rahix Date: Sun, 14 Apr 2019 22:39:53 +0200 Subject: [PATCH] Implement set and call Signed-off-by: Rahix --- bc.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/bc.lua b/bc.lua index f6037877a8bc..329426ec3606 100644 --- a/bc.lua +++ b/bc.lua @@ -157,7 +157,21 @@ function BaseControl:get(noun, timeout) end function BaseControl:set(name, value) - error("set unimplemented") + if self.locals.nouns[name] ~= nil then + if type(value) == "function" then + error("\""..name.."\" can't be cast into a verb") + else + self.locals.nouns[name] = value + end + elseif self.locals.verbs[name] ~= nil then + if type(value) ~= "function" then + error("\""..name.."\" can't be cast into a noun") + else + self.locals.verbs[name] = value + end + else + error("\""..name.."\" is not a local") + end end -- }}} @@ -176,7 +190,11 @@ function BaseControl:verbs(local_only) end function BaseControl:call(verb, ...) - error("call unimplemented") + if self.locals.verbs[verb] ~= nil then + self.locals.verbs[verb](...) + else + error("unknown verb") + end end -- }}} -- }}}