Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EvMenu exec option behavior does not conform to docs, raises traceback #1429

Closed
RyanStein opened this issue Sep 13, 2017 · 7 comments
Closed
Labels
bug An actual error or unwanted behavior.

Comments

@RyanStein
Copy link
Contributor

RyanStein commented Sep 13, 2017

Brief summary of issue / Description of requested feature:

According to the documentation for EvMenu, the exec option on a menu node should call a function and if it returns a single string argument, the menu will redirect to that node instead. It seems like they're being treated like goto options but the return arguments are ignored, and there must be at least two returns or it tracebacks.

Steps to reproduce the issue / Reasons for adding feature:

from evennia.utils.evmenu import EvMenu

def exec1(caller):
    caller.msg('Broken.')
    # According to docs, should be just fine, but requires 2 return args.

def exec2(caller):
    caller.msg("Doesn't TB, but doesn't conform to documentation either.")
    # Should jump to exec1 with only one argument, but requires 2 or traceback.
    # Doesn't jump even with 2 arguments.
    return "exec1", None

def start(caller):
    return "Hello world!", (
        {"desc": "Exec node 1", "exec": "exec1", "goto": "start"},
        {"desc": "Exec node 2", "exec": "exec2", "goto": "start"},
    )

EvMenu(self, {"start": start, "exec1": exec1, "exec2": exec2 }, startnode="start")

Error output / Expected result of feature

Tracebacks if exec does not return two values, which seem to be ignored either way.

Extra information, such as Evennia revision/repo/branch, operating system and ideas for how to solve / implement:

Evennia 0.6 63ccac8

@Griatch
Copy link
Member

Griatch commented Sep 13, 2017

exec1 is actually genuinely invalid according to the docs since it is neither a valid node (returning a text, options tuple) nor a single string which the documentation for the exec does suggest should be possible. So the exec2 example does indead appear to be inconsistent with documentation. I suspect the fault is with docs rather than with code here - since goto can now be a callable as well, there is no need to duplicate that functionality also from the exec. But it's worth looking into and/or clarifying.

@Griatch Griatch added the bug An actual error or unwanted behavior. label Sep 13, 2017
@RyanStein
Copy link
Contributor Author

This example indicates that exec may be used otherwise, without a return value in the manner of a valid node, using the lambdas as demonstrated.

@Griatch
Copy link
Member

Griatch commented Sep 14, 2017

That lambda is a callable directly given to the exec, it's not the same as supplying the name of a node in the Evmenu node tree.

@RyanStein
Copy link
Contributor Author

Sorry, it took me a while to understand that distinction, that a string name of a function is handled completely differently (treated as a node) as opposed to directly providing the function object itself. I think that's where I got tripped up, since it seemed like exec would have treated both the same way (a function to be called as-is) regardless. Thank you for the clarification.

@Griatch
Copy link
Member

Griatch commented Sep 17, 2017

@RyanStein: I however agree this can be made clearer in the doc. :)

@Griatch
Copy link
Member

Griatch commented Oct 1, 2017

The traceback reported, from #1457:

Error in menu node 'check_choice'.
Traceback (most recent call last):
File "c:\users\user\my documents\python\evennia\evennia\commands\cmdhandler.py", line 509, in _run_command
ret = yield cmd.func()
File "c:\users\user\my documents\python\evennia\evennia\utils\evmenu.py", line 266, in func
menu._input_parser(menu, self.raw_string, caller)
File "c:\users\user\my documents\python\evennia\evennia\utils\evmenu.py", line 404, in evtable_parse_input
menuobject.callback_goto(callback, goto, raw_string)
File "c:\users\user\my documents\python\evennia\evennia\utils\evmenu.py", line 733, in callback_goto
self.goto(goto, raw_string)
File "c:\users\user\my documents\python\evennia\evennia\utils\evmenu.py", line 806, in goto
nodetext, options = self._execute_node(nodename, raw_string)
File "c:\users\user\my documents\python\evennia\evennia\utils\evmenu.py", line 698, in _execute_node
nodetext, options = node(self.caller, raw_string)
ValueError: too many values to unpack

An untrapped error occurred.
(Traceback was logged 2017-10-01 19:14:38+1100).
Traceback (most recent call last):
File "c:\users\user\my documents\python\evennia\evennia\commands\cmdhandler.py", line 653, in cmdhandler
unformatted_raw_string, cmdset, session, player)
ErrorReported: 1

@Griatch Griatch changed the title EvMenu exec option behavior does not conform to docs EvMenu exec option behavior does not conform to docs, raises traceback Oct 1, 2017
@Griatch
Copy link
Member

Griatch commented Sep 30, 2018

The exec option for EvMenu is deprecated as of Evennia 0.8 and should not be used if possible - all its functionality can be achieved through goto-callables. Closing.

@Griatch Griatch closed this as completed Sep 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An actual error or unwanted behavior.
Projects
None yet
Development

No branches or pull requests

2 participants