Re: [Evennia] Trouble Adding a Command Prompt

68 views
Skip to first unread message

Kelketek Titikilik Rritaa

unread,
Apr 23, 2013, 12:39:44 PM4/23/13
to eve...@googlegroups.com
Hello there, and welcome to Evennia!

There are a couple of ways you could do this. The first is to add the at_post_cmd hook as you did to MuxCommand, and then make NEW commands subclasses of MuxCommand.

The second is to add it to the base MuxCommand, which the one in examples inherits from. It's located in src, so you shouldn't edit it directly. Instead, monkey-patch the method onto the class using one of the startup hooks.


On Tue, Apr 23, 2013 at 1:59 AM, Andrew Pamment <pam...@gmail.com> wrote:
Hi there,

I'm trying to follow the instructions here: https://code.google.com/p/evennia/wiki/CommandPrompt to add a command prompt. I want to add the first type with the Command prompt after the output.

If I understand correctly, I do this by adding the command prompt code to the at_post_cmd() hook of MuxCommand.

I'm not sure how to do that. This is what I've tried:

I've added an at_post_cmd hook to the MuxCommand defined in gamesrc/commands/examples/command.py with my prompt and renamed the file to gamesrc/commands/basecommand.py
I've copied gamesrc/commands/examples/cmdset.py to gamesrc/commands/examples/basecmdset.py and setup CMDSET_DEFAULT = "game.gamesrc.commands.basecmdset.DefaultCmdSet" in the settings.py

I'm not sure what to do next, it doesn't work, but I'm sure there is something else I need to do to make Evennia see the new MuxCommand with prompt instead of the default one.

I'm a newbie at Python as well, so that doesn't help :)

Thanks,
Andrew

--
--
You received this message because you are subscribed to the "Evennia" MU* server mailing list.
To post to this group, send email to eve...@googlegroups.com (or use the web interface).
To unsubscribe from this group, send email to evennia+u...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/evennia?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Evennia" group.
To unsubscribe from this group and stop receiving emails from it, send an email to evennia+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Griatch Art

unread,
Apr 23, 2013, 6:26:12 PM4/23/13
to eve...@googlegroups.com
Hi Andrew,

It sounds like you do everything right for redirecting Evennia to your own cmdset-location. That should be ready and prepared for you adding your own commands. The problem is (as Kelketek also points out) that even though you modify a copy of MuxCommand and point Evennia to your custom cmdset in game/, that cmdset skeleton by default still points to the default commands in src/commands/default. And those commands are of course using the default MuxCommand (which doesn't have your extension). Your prompt should work just fine once you add new commands to your custom cmdset, commands that actually inherit from your own MuxCommand.

The commands in the src/commands/default are examples intended to be copied over to game and modified as you please. If you only want to change the inheritance, you don't need to copy the whole thing, you can just do something like:

from ev import cmdset_default
from game.gamesrc.commands.basecommand import MyMuxCommand
class CmdLook(MyMuxCommand, cmdset_default.MuxCommand):
    pass

and so on for the commands you want to have your prompt after. Just change your cmdset to import those stub commands from the new location and Evennia will use them, including your custom hook.


Looking at it, I see that the cmdprompt-example wiki page can be confusing here - it is assuming a bit too much about your setup to be useful for a newbie. I'll try to update that with more pertinent info.
 
On a more general note I can also certainly understand that a user would be confused that the at_post_cmd hook doesn't work on existing commands (although it makes perfect Python sense). It's a bit cumbersome to have to copy code just to add the effects of a hook, but the system was designed with the default commands serving primarily as snippets and examples. That said, there might be a point in making them easier to overload with minimal changes, assuming it would be possible without ruining their roles examples of code.
.
Griatch
Reply all
Reply to author
Forward
0 new messages