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

Already on GitHub? Sign in to your account

EvMenu exec option behavior does not conform to docs #1429

Open
RyanStein opened this Issue Sep 13, 2017 · 5 comments

Comments

Projects
None yet
2 participants

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

Owner

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 label Sep 13, 2017

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.

Owner

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.

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.

Owner

Griatch commented Sep 17, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment