mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Make evmenu 'goto' option argument accept a callable for deciding the next node.
This commit is contained in:
parent
5b62a30ce6
commit
0aebbf6975
1 changed files with 13 additions and 1 deletions
|
|
@ -785,12 +785,24 @@ class EvMenu(object):
|
|||
Run a node by name
|
||||
|
||||
Args:
|
||||
nodename (str): Name of node.
|
||||
nodename (str or callable): Name of node or a callable
|
||||
to be called as `function(caller, raw_string)` or `function(caller)`
|
||||
to return the actual goto string.
|
||||
raw_string (str): The raw default string entered on the
|
||||
previous node (only used if the node accepts it as an
|
||||
argument)
|
||||
|
||||
"""
|
||||
if callable(nodename):
|
||||
try:
|
||||
if len(getargspec(nodename).args) > 1:
|
||||
# callable accepting raw_string
|
||||
nodename = nodename(self.caller, raw_string)
|
||||
else:
|
||||
nodename = nodename(self.caller)
|
||||
except Exception:
|
||||
self.caller.msg(_ERR_GENERAL.format(nodename=nodename), self._session)
|
||||
raise
|
||||
try:
|
||||
# execute the node, make use of the returns.
|
||||
nodetext, options = self._execute_node(nodename, raw_string)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue