Skip to content

TinyMUX Softcode

SharpMUSH reads PennMUSH softcode first. TinyMUX softcode is close to it, and most of the places where the two disagree are calls PennMUSH refuses. SharpMUSH answers those calls the way TinyMUX does, so TinyMUX code that uses them runs unchanged, and PennMUSH code that works is not affected.

Where TinyMUX and PennMUSH both give a working answer and the answers differ, SharpMUSH keeps PennMUSH’s by default. Five settings switch to TinyMUX’s answer, for a game whose code was written for TinyMUX: three mux_ settings, innermost_tokens, and rhost_list, which TinyMUX’s list() shares with RhostMUSH.

This page covers:

  • the TinyMUX forms of shared functions, which work on every game;
  • %m and %=<name>, two TinyMUX substitutions;
  • commas in one-argument functions, and the space_compress setting;
  • the mux_logic, mux_justify, mux_collation, innermost_tokens and rhost_list settings;
  • what still has to be rewritten by hand.

Every example below is in the game’s help (help compatibility arguments, help compatibility config, help compatibility parser, help compatibility dialects), and SharpMUSH’s test suite runs them, with TinyMUX 2.14’s own answers as the expected output. The rhost_list section shows the call’s form only.

These work on every game, with no setting:

CallGivesPennMUSH gives
switch(x,default)defaultan argument-count error
add(5), mul(3)5, 3an argument-count error
and(1), or(0), xor(1)1, 0, 1an argument-count error
itext()the innermost loop’s element, as itext(0)an error
lnum()nothingan error
think [switch(x,default)]|[add(5)]|[and(1)]|[lnum()]|[iter(a b,itext())]

Output: default|5|1||a b

An empty call such as add() or and() is still PennMUSH’s argument-count error.

TinyMUX’s wrap() pads every line to the width and justifies it:

wrap(<text>, <width>, <justify>, <left>, <right>, <hanging>, <osep>, <first width>)

SharpMUSH uses this form when a call has more than four arguments, or when its third argument starts with a letter (left, right, center, or just l, r, c). A third argument that is a number, or empty, is PennMUSH’s first line width.

think wrap(aaa bbb ccc,7,center,<,>,2)

Output:

<aaa bbb>
< ccc >

<left> and <right> frame each line, lines after the first start with <hanging> spaces, <osep> goes between lines (a line break by default, @@ for nothing), and <first width> is the width of the first line.

setunion(), setinter(), setdiff() and setsymdiff() take the output separator before the sort type in TinyMUX, and after it in PennMUSH. With five arguments, SharpMUSH reads TinyMUX’s order when the fourth argument is not a sort type and the fifth is:

think setunion(B a c,b, ,|,a)

Output: B|a|b|c

With four arguments TinyMUX reads the fourth as the separator and PennMUSH as the sort type. SharpMUSH reads it as PennMUSH does, unless mux_arguments is on, which a TinyMUX import turns on.

%m is TinyMUX’s name for the command being run, which is %c in PennMUSH and SharpMUSH. Both work.

think %m|%c

Output: think %m|%c|think %m|%c

%=<name> is the attribute <name> on the object running the code, the same as v(<name>). When <name> is a number, it is that argument, so %=<12> reaches past %9 the way %<12> does.

&GREETING me=hello
think %=<greeting>

Output: hello

%= on its own works as it does in PennMUSH. It is the attribute being evaluated, written as the object’s dbref and the attribute’s name, and it is empty outside an attribute:

&WHERE me=%=
think u(me/WHERE)

Output, for a player who is #3: #3/WHERE

In code read in the mux dialect, a function that takes one argument reads any commas in it as text, as TinyMUX does, so strlen(a,b) is 3. That is code in an attribute with the mux flag, which a TinyMUX import sets on every attribute it brings in. While the game’s dialect setting is mux, it is also anything typed and code in an attribute with no dialect flag. The rhost dialect reads these commas the same way (see the RhostMUSH guide); elsewhere strlen(a,b) passes two arguments. This covers capstr(), escape(), flip() (and reverse()), lcstr(), lit(), s(), secure(), sha1(), strlen(), strmem(), t() and ucstr().

With dialect set to mux:

think [strlen(a,b)] [ucstr(a, b)]

Output: 3 A, B

SharpMUSH makes each run of spaces in evaluated text one space, as PennMUSH and TinyMUX do by default. A game whose netmux.conf turns space_compress off keeps its spaces: importing that file turns SharpMUSH’s space_compress setting off too, and @config/set space_compress=no does the same by hand.

Each of these is off by default. Turn one on with @config/set, for example @config/set mux_logic=yes, or on the web portal’s configuration page. They take effect on the next call.

and(), or(), xor(), cand() and cor() test each argument by the number it starts with, as TinyMUX does, so abc is false. xor() is true when an odd number of arguments are true, not only when exactly one is. t(), if() and the rest keep the game’s usual rule.

think [and(1,abc)]|[or(0,abc)]|[xor(1,1,1)]

Output with mux_logic off: 1|1|0. With it on: 0|0|1.

ljust(), rjust() and center() cut text that is longer than the width, as TinyMUX does. A fourth argument of 0 to ljust() or rjust() still keeps the whole text.

think [ljust(abcdef,3)]|[center(abcdefg,3)]

Output with mux_justify off: abcdef|abcdefg. With it on: abc|abc.

sort() with no sort type, and comp() with no type, put text in TinyMUX’s order: by letter first, then lower case before upper case. A sort type or a comp() type in the call is not affected.

think [sort(b A a B)]|[comp(a,B)]

Output with mux_collation off: A a b B|1. With it on: a A b B|-1.

## and #@ read the innermost iter() or @dolist that is running, and #$ the innermost switch whose action is running, wherever the token is written, as TinyMUX does. They also work in the code of an attribute the pattern calls, such as through u(). With it off, they read the outermost one whose text they are written in, as PennMUSH does.

A few functions read the same arguments differently on the two servers. With mux_arguments on they read them as TinyMUX does: the set functions take a fourth argument as the output separator, hmac() takes its digest third, lwho() with one argument lists connections, channels() takes TinyMUX’s arguments, and textfile() (like dynhelp()) reads an object’s HELP_ attributes when its first argument names no text file. See the option’s help.

trigger() and verb() queue an attribute’s actions from inside a function, as TinyMUX’s do. With the setting off, both return #-1 FUNCTION DISABLED.

The /quiet switch of drop, get, give, goto, enter, leave and @teleport does what TinyMUX’s does, and only on what you control. drop, get and goto leave out the o-message and the action. enter and leave leave out the object’s enter or leave messages, but still run its action and your @move. give/quiet is for wizards and leaves out the usual notices, and @teleport/quiet keeps leaving and arriving quiet but still runs @move. With the setting off, /quiet leaves out your own message and the o-message, and the action still runs.

A global @function defined without /privileged runs as whoever calls it, as on TinyMUX. With it off, it runs as the object that holds its attribute, as on PennMUSH.

These two are shared with RhostMUSH. protection_flags makes the NOEXAMINE and NOMODIFY flags protect what holds them from everyone below wizard and royalty. attribute_eval_flags makes an attribute set noeval give its value as written, and a $-command set noparse match the command as typed. See compatibility config.

PennMUSH’s list() names the game’s functions, commands, flags and so on. TinyMUX’s list(<list>, <action>[, <delimiter>]) is a loop like iter() that tells you each result instead of returning it. With rhost_list on, list() is that loop.

The setting is named for RhostMUSH because RhostMUSH’s list() is the same loop with two more arguments: list(<list>, <action>[, <delimiter>][, <header>][, <target>]), where <header> is a line told before the results and <target> is an object you control to tell them to, instead of you. TinyMUX’s three-argument form is the start of that one, so rhost_list runs list() calls written for either server. With it on, @list still names the game’s functions, commands and flags.

  • trim() takes its arguments in TinyMUX’s order when tiny_trim_fun is on; trimtiny() always does.
  • columns() is RhostMUSH’s, columns(<text>, <width>, <columns>, ...), which takes the number of columns as its third argument. TinyMUX’s columns(<list>, <width>[, <delimiter>[, <indent>]]) is a different function, so calls to it have to be rewritten, for example with table() or align().
  • Mail drafts are not supported. TinyMUX’s @mail <player>=<subject> opens a draft that - and ~ add to and -- or @mail/send sends; SharpMUSH has no draft, and @mail <player>=<text> sends <text> at once. Write each message in one command with @mail/quick <player>/<subject>=<message>, which works as it does on TinyMUX, or use the web portal’s mail page. See help compatibility mail.
  • Some functions only TinyMUX has are not there. pack() and unpack() are; see RhostMUSH Softcode for how unpack() treats a character that is not a digit.