Multiple things to send (parameters) can be sent using functionName(parameter, parameter2, parameter3). Note the format for calling functions - it is functionName(things to send). An example alias, and its output, is below:Ī simple example of a real script I use is an infoEcho() - on the system I'm building, I like a pretty format display to come up on my screen that reads. When you type in an alias into the input line, instead of sending the text to the MUD, it will execute the code.
I'll go a little more in-depth after each is explained, so if you're already solid on these feel free to skip ahead.Īn alias is nothing more than a shortcut. Before we go any further, it is important to know what these things are, so allow me to give an overview. There are four aspects to coding within Mudlet. I'm sure I've left something off from here, so lemme know and I'll add it. It's about as clear as mud to a newbie (heh, MUD/mud) - but if you remember it, you'll be ok. If you want the FIRST VARIABLE YOU USED A WILDCARD FOR, use matches. Please note this, because it messes newbies up lots. So for matches, we'd do matches to see the WHOLE LINE. To reference a specific part of an array, we use the format arrayName. And ok we're back - so the values we save from a trigger are stored in an array called matches. An array is a bunch of boxes that exist in numbered order. To do that, we're going to touch upon another topic briefly and then run away screaming: an array. Additionally, if you have a wildcard that you don't want to save for later? Just drop off the ()s and leave it as \w+ or whatever - they won't mind.Īnd now that you've crammed some value into your new best friend (remind me to never be friends with you), you're going to want to pull it out some time. Don't look now, but there's a number behind you!īe careful with (.+) and (.*) - they're REALLY grabby. You suddenly feel like eating a giant pickle sundae. What if it's two words? Or.or three words? OR MORE THAN THREE?! If we need a placeholder for a single word? Do you have 1 gold, or 100000 gold? Did you swing an elegant rapier inlaid with rubies, or a short cudgel covered in grease? These questions would matter if it wasn't for wildcards - your new best friend. Maybe it's you punching yourself - maybe it was always you punching yourself. Sometimes we don't know what's going to happen. You can add/subtract/multiply/divide variables and numbers freely. + for addition, - for subtraction, * for multiplication and / for division. And it will crash your Mudlet, and if you go have a cry I won't judge you because I do it all the damn time. Please note that this will execute forever if text and number are the same, unless you have some way within the loop for that condition to no longer be true. The most common one I use is the WHILE loop. You can do several other kinds of statements - loops. It means exactly how it reads: IF the variable 'text' EQUALS the variable named 'number', THEN do whatever. The statement exemplified above is an 'if' statement. If we want to COMPARE variables, we use = Number = text -This is how you'd copy a variable's value Nil means 'there's no value at all in here'. Truefalse = true -true, false and nil are booleans. Text = "This is how you store a string of text!" Variables are initialized in Mudlet by doing simply variableName = value.
I'm sure this quick'n'dirty thing won't cover something - if you think of something easy that I missed, let me know and I'll add it! I'd rather assume nothing, and leave nothing to chance. This isn't the only post I'll make (hopefully?) but it is going to be the first one for awhile (because man this took like an hour!) So, without further ado, here we go. While it'll be Mudlet-oriented, the beginning bits will at least generalize to other clients as well (or so I assume).
So, I've decided to write a basic guide for coding in MUDs.