@Groth said:
So looking through the Evennia documentation it seems to support most things that builders would expect out of softcode. The main thing it does not support is the ability to define commands however in my experience builders do not usually need or want to define commands.
The bigger issue I see is that the command library looks rather sparse. For instance their example smile command looks like this
from evennia import Command
class CmdSmile(Command):
"""
A smile command
Usage:
smile [at] [<someone>]
grin [at] [<someone>]
Smiles to someone in your vicinity or to the room
in general.
(This initial string (the __doc__ string)
is also used to auto-generate the help
for this command)
"""
key = "smile"
aliases = ["smile at", "grin", "grin at"]
locks = "cmd:all()"
help_category = "General"
def parse(self):
"Very trivial parser"
self.target = self.args.strip()
def func(self):
"This actually does things"
caller = self.caller
if not self.target or self.target == "here":
string = "%s smiles." % caller.name
caller.location.msg_contents(string, exclude=caller)
caller.msg("You smile.")
else:
target = caller.search(self.target)
if not target:
# caller.search handles error messages
return
string = "%s smiles to you." % caller.name
target.msg(string)
string = "You smile to %s." % target.name
caller.msg(string)
string = "%s smiles to %s." % (caller.name, target.name)
caller.location.msg_contents(string, exclude=[caller,target])
That is not a reasonable way for such a simple function to be written. One of the few strengths of MUSHcode is that it has very powerful and easy to use parsers built in and all the relevant variables like the caller, target, arguments etc are already pre-stored into default substitutions variables.
@Groth
Ah, I guess I should take my first post on musoapbox (hello everybody) to comment on this technical aspect of Evennia's design. For full disclosure - I'm the Evennia lead developer.
Evennia actually does make a minimum of "relevant" variables available in its base Command class. For example you will find self.args (the arguments to this command), self.caller (who called this command) and so on already available on the Command instance. There are some 10 dynamic variables available to the Command at runtime related to the call of it, the object it is assigned to and so on.
The Command class is however (by default) not knowing anything about what syntax you want your commands to support - all it knows at this point is that it has figured out what command-name is being called (the first part of your input, which can have any length, including spaces, how we determine this uniquely is a technical issue I'll leave for now) - the rest of the input string is just dropped in self.args. It's now up to you to parse that.
Now, it may sound like you need to do a lot of parsing all the time (and the smile example is just that - an example where a simple parser was introduced). But the thinking behind the Command system is that Commands are Python classes, and those can be inherited. This means that you implement the parse() method once, storing all the "relevant variables" the way you want. You could also make a little helper method to easily template your return messages to your particular preference (Python excels at string manipulation after all). All other commands that share a similar syntax can now inherit from your custom "MUSHCommand" class and not have to worry about parsing themselves - you'll have all the convenient variables available directly in func(), where you want them to do whatever your command should do.
This is in fact how we implement our "MUX-like" default commands throughout Evennia: they all inherit from MuxCommand, which parses the incoming argument into understanding stuff like /switches, the use of = for assignment and so on. We have a second base class for some admin commands which (some of which were originally borrowed from a MUX flavor) really go all out in syntax complexity ...
Is Evennia's Python code more verbose than softcode, covering more lines for the same functionality? I've not done a comparison - my softcode skills are severely lacking I must admit - but you are probably correct in that.
As for the default command library, there are currently about 90 commands in Evennia's default set I think. These are by no means intended to be comprehensive though; most are admin-level stuff (boring stuff all games need). We expect most commands will be modified to fit each game anyway. We could certainly offer more Commands to build from in our contrib/ folder though, this is a slowly growing resource.
.
Griatch