Evennia for MUSHers


  • Coder

    If you are a MUSH user interested in trying to make your next game in Evennia but are unsure where to start, this is the introduction for you! It will go through some key differences, help with the installation and then offer some first things to try out.

    On Evennia

    Evennia googly snake
    Evennia is an open-source game server and -library for developing multiplayer text-games in Python (not only MUSH, any type of MU*). When you start Evennia you’ll have a fully functioning (if empty) game that you can connect to with normal MU* clients as well as play from any modern browser - you will also get a simple website for your game.

    By default you’ll have some 90 in-game commands as well as channels, rooms, characters and other basic building blocks. Commands can be completely changed but the default administrative command syntax is somewhat reminiscent of MUX.

    Fundamental differences between MUSH and Evennia

    Apart from the features mentioned above, Evennia works quite differently from a MUSH under the hood. Here are some fundamental differences to keep in mind.

    Developers vs Players

    In MUSH, users tend to code and expand all aspects of the game from inside it. A MUSH can thus be said to be managed solely by Players with different levels of access. Evennia on the other hand, differentiates between the role of the Player and the Developer.

    • An Evennia Developer works in Python from outside the game, in what MUSH would consider “hardcode”. Developers implement larger-scale code changes and can fundamentally change how the game works. They then load their changes into the running Evennia server. Such changes will usually not drop any connected players.
    • An Evennia Player operates from inside the game. Some staff-level players are likely to double as developers. Depending on access level, players can modify and expand the game's world by digging new rooms, creating new objects, alias commands, customize their experience and so on. Trusted staff may get access to Python via the @py command, but this would be a security risk for normal Players to use. So the Player usually operates by making use of the tools prepared for them by the Developer - tools that can be as rigid or flexible as the developer desires.

    Collaborating on a game - Python vs Softcode

    For a Player, collaborating on a game need not be too different between MUSH and Evennia. The building and description of the game world can still happen mostly in-game using build commands, using text tags and inline functions to prettify and customize the experience. Evennia offers external ways to build a world but those are optional. There is also nothing in principle stopping a Developer from offering a softcode-like language to Players if that is deemed necessary.

    For Developers of the game, the difference is larger: Code is mainly written outside the game in Python modules rather than in-game on the command line. Python is a very popular and well-supported language with tons of documentation and help to be found. The Python standard library is also a great help for not having to reinvent the wheel. But that said, while Python is considered one of the easier languages to learn and use it is undoubtedly very different from MUSH softcode.

    While softcode allows collaboration in-game, Evennia's external coding opens up for sharing using professional version control tools and bug tracking using websites like github (or bitbucket for a free private repo). Source code can be written in proper text editors and IDEs with refactoring, syntax highlighting and all other conveniences. In short, collaborative development of an Evennia game is done in the same way most professional collaborative development is done in the world, meaning all the best tools can be used.

    @parent vs @typeclass and @spawn

    Inheritance works differently in Python than in Softcode. Evennia has no concept of a "master object" that other objects inherit from. There is in fact no reason at all to introduce "virtual objects" in the game world - code and data are kept separate from one another.

    In Python (which is an object oriented language - read the wikipedia article for the advantages of this) one instead creates classes - these are like blueprints from which you spawn any number of object instances. Evennia also adds the extra feature that every instance is persistent in the database (this means no SQL is ever needed). To take one example, a unique character in Evennia is an instances of the class Character.

    One parallel to MUSH's @parent command may be Evennia's @typeclass command, which changes which class an already existing object is an instance of. This way you can literally turn a Character into a Flowerpot on the spot.

    if you are new to object oriented design it's important to note that all object instances of a class does not have to be identical. If they did, all Characters would be named the same. Evennia allows to customize individual objects in many different ways. One way is through Attributes, which are database-bound properties that can be linked to any object. For example, you could have an Orc class that defines all the stuff an Orc should be able to do (probably in turn inheriting from some Monster class shared by all monsters). Setting different Attributes on different instances (different strength, equipment, looks etc) would make each Orc unique despite all sharing the same class.

    The @spawn command allows one to conveniently choose between different "sets" of Attributes to put on each new Orc (like the "warrior" set or "shaman" set) . Such sets can even inherit one another which is again somewhat remniscent at least of the effect of @parent and the object-based inheritance of MUSH.

    There are other differences for sure, but that should give some feel for things. Enough with the theory. Let's get down to more practical matters next.

    Getting Evennia running

    Evennia runs on Linux/Unix, Windows and Mac. Most of the install is handled automatically but you must be familiar with the Linux/Mac terminal or the Windows console. The full install instructions (and explanations of each step) are found on the Evennia Getting Started page - look there if you run into trouble.

    1. Install Python, python-virtualenv and GIT in the way recommended by your OS. On a Debian-derived Linux (Ubuntu etc), you can do sudo apt-get install python python-dev git python-virtualenv. After this you should not need to be root/admin anymore.
    2. Create a new folder, say mud-dev, somewhere - for example in your home directory on Linux/Mac or in My Documents on Windows.
    3. Open the terminal/console and cd to the mud-dev folder. You'll stay in here from now on.
    4. Enter virtualenv pyenv - a new folder pyenv will appear. The virtualenv program allows you to install Python libraries in the pyenv folder without affecting other things on your system - it's a standard Python practice.
    5. Enter source pyenv/bin/activate (Linux/Mac) or pyenv\Scripts\Activate (Windows). This activates the virtualenv. You see that it works if the text (pyenv) appears next to the command prompt. You need to call this command every time you open a new terminal to get access to the stuff you install in the virtualenv below.
    6. git clone https://github.com/evennia/evennia.git - a new directory evennia will appear; this holds the actual Evennia code.
    7. pip install -e evennia - installs Evennia to the virtual environment. You should now have the evennia command available - try it! If there are any hick-ups, look here for linux-, mac- and windows troubleshooting respectively.
    8. Enter evennia --init mygame - this will create a new folder mygame (or whatever you choose to call it) where we’ll create our new game.
    9. cd mygame
    10. evennia migrate - this will create the database.
    11. evennia start - the server starts. You can now telnet to it on localhost, port 4000 or in your browser on http://localhost:8000.

    Welcome to Evennia! If you want to toy around you can get some first pointers in the "Next Steps" section last in this how-to. Take a moment to try things out, maybe build the tutorial world as instructed in the first room. Some things will look familiar, other things not, we’ll start addressing that in the next section.

    A first step making things more familiar

    We will here give two examples of customizing Evennia to be more familiar to a MUSH Player.

    Activating a multi-descer

    By default Evennia’s desc command updates your description and that’s it. There is a more feature-rich optional “multi-descer” in evennia/contrib/multidesc.py though. This alternative allows for managing and combining a multitude of keyed descriptions.

    To activate the multi-descer, cd to your game folder and into the commands sub-folder. There you’ll find the file default_cmdsets.py. In Python lingo all *.py files are called modules. Open the module in a text editor. We won’t go into Evennia in-game Commands and Command sets further here, but suffice to say Evennia allows you to change which commands (or versions of commands) are available to the player from moment to moment depending on circumstance.

    Add two new lines to the module as seen below:

    # the file mygame/commands/default_cmdsets.py
    # [...] 
    
    from evennia.contrib import multidescer   # <- added now
    
    class CharacterCmdSet(default_cmds.CharacterCmdSet):
        """
        The CharacterCmdSet contains general in-game commands like look,
        get etc available on in-game Character objects. It is merged with
        the PlayerCmdSet when a Player puppets a Character.
        """
        key = "DefaultCharacter"
    
        def at_cmdset_creation(self):
            """
            Populates the cmdset
            """
            super(CharacterCmdSet, self).at_cmdset_creation()
            #
            # any commands you add below will overload the default ones.
            #
            self.add(multidescer.CmdMultiDesc())      # <- added now 
    # [...]
    

    Note that Python cares about indentation, so make sure to indent with the same number of spaces as shown above!

    So what happens above? We import the module evennia/contrib/multidescer.py at the top. Once imported we can access stuff inside that module using full stop (.). The multidescer is defined as a class CmdMultiDesc (we could find this out by opening said module in a text editor). At the bottom we create a new instance of this class and add it to the CharacterCmdSet class. For the sake of this tutorial we only need to know that CharacterCmdSet contains all commands that should be be available to the Character by default.

    This whole thing will be triggered when the command set is first created, which happens on server start. So we need to reload Evennia with @reload - no one will be disconnected by doing this. If all went well you should now be able to use desc (or +desc) and find that you have more possibilities:

    > +desc eyes = His eyes are blue. 
    > +desc basic = A big guy.
    > +desc/set basic + + eyes    # we add an extra space between
    > look me
    A big guy. His eyes are blue.
    

    (See also help +desc). If there are errors a traceback will show in the server log - several lines of text showing where the error occurred. Find where the error is by locating the line number related to the default_cmdsets.py file (it's the only one you've changed so far). Most likely you mis-spelled something or missed the indentation. Fix it and either @reload again or run evennia start as needed.

    Customizing the multidescer syntax

    As seen above the multidescer uses syntax like this (where |/ are Evennia's tags for line breaks) :

    > +desc/set basic + |/|/ + cape + footwear + |/|/ + attitude 
    

    This use of + was prescribed by the Developer that coded this +desc command. What if the Player doesn’t like this syntax though? Do players need to pester the dev to change it? Not necessarily. While Evennia does not allow the player to build their own multi-descer on the command line, it does allow for re-mapping the command syntax to one they prefer. This is done using the nick command.

    Here’s a nick that changes how to input the command above:

    > nick setdesc $1 $2 $3 $4 = +desc/set $1 + |/|/ + $2 + $3 + |/|/ + $4
    

    The string on the left will be matched against your input and if matching, it will be replaced with the string on the right. The $-type tags will store space-separated arguments and put them into the replacement. The nick allows shell-like wildcards, so you can use *, ?, [...], [!...] etc to match parts of the input.

    The same description as before can now be set as

    > setdesc basic cape footwear attitude 
    

    With the nick functionality players can mitigate a lot of syntax dislikes even without the developer changing the underlying Python code.

    Next steps

    If you are a Developer and are interested in making a more MUSH-like Evennia game, a good start is to look into the Evennia Tutorial for a first MUSH-like game. That steps through building a simple little game from scratch and helps to acquaint you with the various corners of Evennia. There is also the Tutorial for running roleplaying sessions that can be of interest.

    An important aspect of making things more familiar for Players is adding new and tweaking existing commands. How this is done is covered by the Tutorial on adding new commands. You may also find it useful to shop through the evennia/contrib/ folder. The Tutorial world is a small single-player quest you can try (it’s not very MUSH-like but it does show many Evennia concepts in action). Beyond that there are many more tutorials to try out. If you feel you want a more visual overview you can also look at Evennia in pictures.

    … And of course, if you need further help you can always drop into the Evennia chatroom or post a question in our forum/mailing list!



  • Thank you for this. :D I like to tinker with things and see what they do and how they work. I'll likely peek at this in the same way, and I appreciate the mac support and instructions.

    (Anybody giving good mac support gets a major thumbs up from me. It's rare enough it deserves a specific mention and a sincere thank you.)


  • Coder

    I can verify that the Evennia chat room is open, friendly, and usually appropriately silly. The occasions I've seen tensions rise, others have stepped in to say, "Hey, okay, let's not go there." Even tho I've done little there but kind of trade witty repartee with @Volund.


  • Coder

    @surreality said in Evennia for MUSHers:

    Thank you for this. :D I like to tinker with things and see what they do and how they work. I'll likely peek at this in the same way, and I appreciate the mac support and instructions.

    (Anybody giving good mac support gets a major thumbs up from me. It's rare enough it deserves a specific mention and a sincere thank you.)

    Sure! We try to help as we can. Python is OS-agnostic so the only real difference is where to get the dependencies during install. Mac tends to install fine though, it's more common with Windows-install questions.

    @Thenomain said in Evennia for MUSHers:

    I can verify that the Evennia chat room is open, friendly, and usually appropriately silly. The occasions I've seen tensions rise, others have stepped in to say, "Hey, okay, let's not go there." Even tho I've done little there but kind of trade witty repartee with @Volund.

    Glad you think so! It can drift off topic quite a bit occationally, but most of the time we do talk MU*, I promise.

    As an aside, it still irks me that for the longest time the only other comment mentioning our chatroom online was some fellow complaining about it (in another forum I'm not part of). S/he replied to a thread about Evennia, being sad that our chatroom was inactive and thus not very useful . This in itself wouldn't annoy me if I didn't happen to remember that particular nickname in the logs. Before that post they joined the chatroom once, for all of ten minutes. On Christmas Eve.
    .
    Griatch



  • @Griatch said in Evennia for MUSHers:

    S/he replied to a thread about Evennia, being sad that our chatroom was inactive and thus not very useful . This in itself wouldn't annoy me if I didn't happen to remember that particular nickname in the logs. Before that post they joined the chatroom once, for all of ten minutes. On Christmas Eve.

    This mentality really bothers me. I see it pretty consistently. 'X is inactive because nobody was on at 4am US Eastern Time on a Monday night.' I do not know wtf these people expect, other than sentient robots who cater them constantly everywhere online.

    Anyway, the tutorial! It looks really neat, and I'll play around with the Tutorial World when I have a moment.


  • Coder

    @Thenomain
    You should speak up more!

    ... and I need to check musoapbox more.

    I can attest that Evennia, while wildly different from Penn, Rhost, and other modern MUSH/MUX-style codebases, is quite easy to jump into, especially if you already know object oriented programming. While my own experiences have been plagued by constant bouts of RL dragging my interests elsewhere, or getting too involved in a MUSHcode project, or just having way too much fun RP'ing... going by my actual time spent hammering away at Python code? I've spent 3 months or so re-creating what took me six years to learn to do in MUSHcode (obviously not 24/7, this being everything I learned that eventually lead up to the polished code package - which still must have been hundreds if not thousands of hours), and am pushing it to heights that would have been completely untenable in MUSHcode.

    I'm not going to say that Evennia is the best option for all cases. It may well be that the longest-standing MUX/MUSH games have little need of it, but Evennia opens new horizons and possibilities that are DEFINITELY worth exploring and working with. I feel that, if I can spend enough time working on this and can refine my own framework project ('Athanor' on my volundmush github, totally just me doinking around right now) I may be able to leave softcode behind entirely on day.

    However, I will say that any newbies looking to get into making a MU* style game are probably better off spending their time learning Python than MUSHcode. As loyal as I am to Penn and Rhost communities, there's just no comparison, and you can count the amount of games that take full advantage of the MUSH-style on-line building these days on one hand. Most of the games I've helped make? Admin do not want people adding to the grid or making new channels or creating an NPC that wanders around the grid trolling people by listening to what they say and chatbotting back at them.


  • Coder

    @Volund said in Evennia for MUSHers:

    [...] you can count the amount of games that take full advantage of the MUSH-style on-line building these days on one hand. Most of the games I've helped make? Admin do not want people adding to the grid or making new channels or creating an NPC that wanders around the grid trolling people by listening to what they say and chatbotting back at them.

    This is an interesting observation. In the first Evennia-related thread I took part in here on Musoapbox, some commenters rather sternly pointed out their need for player-accessed softcode in order to get optimal enjoyment from their game. I'm not involved enough in the mush world to have a feel for the overall statistics of this need, but it surprises me a little if, from what you say, only a minority of mushes actually offers player-open softcoding.
    .
    Griatch



  • @Griatch Actually, a number of folks just go ahead and do it.

    Building (areas) is fairly specific; a number of games allow this, but restrict the object creation to staff. They then allow players to create the descriptions and effects for the object itself.

    Wandering monsters generally aren't much of a thing on the whole.

    People with custom-coded commands for descers, individualized +who lists, and similar, though? That tends to happen quite a lot.

    It tends to be the actual creation of objects that gets restricted to staff on the game level, not the adding of code to those objects.


  • Coder

    Yeah, a fair handful of people I've encountered do like making aliases for accessing inconveniently named channels (Evennia handles this natively with the MUX-style addcom) but I've yet to encounter someone who made a custom +who. They're almost certainly out there on the games I help manage, but I only notice when someone asks for HELP with something...

    I don't make it a habit of scanning people to see who has softcode on them.


  • Pitcrew

    I was one of the big proponents of being able to use softcode in the last conversation and i still am.
    Most of what I use it for basically to let me do tasks I do often quicker, such as WoD power activation, or shifting in places that did not have a shift code set up so I could make a quick shift command and have it macroed in to change my name, desc, etc to fit the new form my character had taken. Now every recent game I have played a shifter on has had shift code in place so it is less of a practical issue in that case anymore.
    I have not had to really use any of my limited soft code tricks because now the games have things set up so there is less of a need to come up with them from a player side of things. though I still like having the ability to if the need should arise.


  • Coder

    @ThatGuyThere said in Evennia for MUSHers:

    I was one of the big proponents of being able to use softcode in the last conversation and i still am.
    Most of what I use it for basically to let me do tasks I do often quicker, such as WoD power activation, or shifting in places that did not have a shift code set up so I could make a quick shift command and have it macroed in to change my name, desc, etc to fit the new form my character had taken. Now every recent game I have played a shifter on has had shift code in place so it is less of a practical issue in that case anymore.
    I have not had to really use any of my limited soft code tricks because now the games have things set up so there is less of a need to come up with them from a player side of things. though I still like having the ability to if the need should arise.

    So if I understand you right, your main use case is to to alias commands to your own needs (such as entering something short to abbreviate a longer series of commands).

    Out of curiosity, if you look at the example of Evennia's "nick" Command in the tutorial above, do you think that could replicate to some extent the aliasing you'd now use softcode for?
    .
    Griatch


  • Pitcrew

    @Griatch
    For the most part, yes it looks like it would.


  • Coder

    Is it handy to have the ability for players to create their own custom code? Absolutely.

    Is it so necessary that you can't live without it? I challenge 'no'. I also challenge that it isn't even important enough to warrant a special in-game interface for doing so.

    Find out what people want to customize and let them customize it through the regular command interfaces. Skins, custom options, etc.


  • Coder

    @Griatch said in Evennia for MUSHers:

    @ThatGuyThere said in Evennia for MUSHers:

    I was one of the big proponents of being able to use softcode in the last conversation and i still am.
    Most of what I use it for basically to let me do tasks I do often quicker, such as WoD power activation, or shifting in places that did not have a shift code set up so I could make a quick shift command and have it macroed in to change my name, desc, etc to fit the new form my character had taken. Now every recent game I have played a shifter on has had shift code in place so it is less of a practical issue in that case anymore.
    I have not had to really use any of my limited soft code tricks because now the games have things set up so there is less of a need to come up with them from a player side of things. though I still like having the ability to if the need should arise.

    So if I understand you right, your main use case is to to alias commands to your own needs (such as entering something short to abbreviate a longer series of commands).

    Out of curiosity, if you look at the example of Evennia's "nick" Command in the tutorial above, do you think that could replicate to some extent the aliasing you'd now use softcode for?
    .
    Griatch

    Something you could look at (that I've not been able to figure out but you may have better luck than I have) is a sandboxed method to allow in-game transposing of a limited python or similar scripted language in-game.

    The issue I always run across is using any mature language in-game allows too much control and allows escaping the sandbox to the server running below it. I've not yet found a clean and safe way around this. But I think that's the golden ticket for future mud based gaming. A mature language system in-game that allows a safe and configurable complexity in a completely safe sandbox.

    I'm still poking at things, and if I find a solution I'll absolutely let the mud community know, but so far, no joy :)


  • Coder

    @Ashen-Shugar said in Evennia for MUSHers:

    @Griatch said in Evennia for MUSHers:

    @ThatGuyThere said in Evennia for MUSHers:

    I was one of the big proponents of being able to use softcode in the last conversation and i still am.
    Most of what I use it for basically to let me do tasks I do often quicker, such as WoD power activation, or shifting in places that did not have a shift code set up so I could make a quick shift command and have it macroed in to change my name, desc, etc to fit the new form my character had taken. Now every recent game I have played a shifter on has had shift code in place so it is less of a practical issue in that case anymore.
    I have not had to really use any of my limited soft code tricks because now the games have things set up so there is less of a need to come up with them from a player side of things. though I still like having the ability to if the need should arise.

    So if I understand you right, your main use case is to to alias commands to your own needs (such as entering something short to abbreviate a longer series of commands).

    Out of curiosity, if you look at the example of Evennia's "nick" Command in the tutorial above, do you think that could replicate to some extent the aliasing you'd now use softcode for?
    .
    Griatch

    Something you could look at (that I've not been able to figure out but you may have better luck than I have) is a sandboxed method to allow in-game transposing of a limited python or similar scripted language in-game.

    The issue I always run across is using any mature language in-game allows too much control and allows escaping the sandbox to the server running below it. I've not yet found a clean and safe way around this. But I think that's the golden ticket for future mud based gaming. A mature language system in-game that allows a safe and configurable complexity in a completely safe sandbox.

    I'm still poking at things, and if I find a solution I'll absolutely let the mud community know, but so far, no joy :)

    Alas, I have already gone down this route and had to discard it. A few years ago I created Evlang as a plugin to Evennia. Evang was a highly stunted subset of Python where I used whitelisting to allow only very limited parts of the language to operate. For a while I was carefully optimistic about it.

    The problem is that Python's awesome introspection ability is its own enemy here: the language is just so very flexible that you as a developer cannot honestly claim to have created a safe production sandbox even if you stunt it to the level I did - Python is simply not designed to be run by untrusted coders. After finding maintenance to be a big problem across Python versions and that people could use Evlang to (in an admittedly very deliberate and obscure way) build loops that ate all memory, I decided to scrap the Evlang project. I could not honestly claim to think it was safe. It's still available in one of the Evennia-organisation's github repositories if you want to take a gander.

    The closest I know of a real Python sandbox is the PyPy project''s specially compiled python interpreter that offers that possibility. We have not explored this for Evennia but since you require compilation anyway it might be worth to look into.
    .
    Griatch


  • Coder

    @Griatch said in Evennia for MUSHers:

    The closest I know of a real Python sandbox is the PyPy project''s specially compiled python interpreter that offers that possibility. We have not explored this for Evennia but since you require compilation anyway it might be worth to look into.
    .
    Griatch

    Yup, you've ran into the same problems I have run into.

    pypy also doesn't cut the bill at the current base because it still has tags into the strict hardware layer itself of the server running under it.

    So while it is marginally sandboxed, it still allows race conditions and jumping permissions by tagging into device drivers. So it's still half-baked as a security model.
    It also has known memory leaks.

    Maybe sometime someone will get a working sandbox model, but right now it's a bit like:


  • Coder

    @Ashen-Shugar said in Evennia for MUSHers:

    pypy also doesn't cut the bill at the current base because it still has tags into the strict hardware layer itself of the server running under it.

    So while it is marginally sandboxed, it still allows race conditions and jumping permissions by tagging into device drivers. So it's still half-baked as a security model.
    It also has known memory leaks.

    Good to know; hadn't looked too close at PyPy's sandbox in a long while.
    .
    Griatch


  • Coder

    Thanks for the how-to, @Griatch.

    You were the only entry, but I still appreciate the submission. Send me a message with your preferred email account address, and I'll send you the first place reward via paypal.


  • Coder

    @Glitch

    Okay! Too bad there weren't any more entries. The idea of contests like this is a good one to instill creativity and actually get stuff done with a deadline; ever since Optional Realities ran their contests I've pondered running something Evennia-centric along similar lines. Time will tell.
    .
    Griatch


Log in to reply
 

Looks like your connection to MU Soapbox was lost, please wait while we try to reconnect.