Implement set and call
Signed-off-by: Rahix <rahix@rahix.de>
This commit is contained in:
parent
3508870c7f
commit
f9a14ecaeb
1 changed files with 20 additions and 2 deletions
22
bc.lua
22
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
|
||||
-- }}}
|
||||
-- }}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue