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;
  • 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), 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 the two servers disagree in a way no rule can settle: TinyMUX reads the fourth as the separator and PennMUSH as the sort type. SharpMUSH reads it as PennMUSH does, so a TinyMUX setunion(<list1>,<list2>,<delimiter>,<osep>) has to become setunion(<list1>,<list2>,<delimiter>,,<osep>).

%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

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.

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.
  • TinyMUX’s four-argument set functions, described above.
  • 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().
  • Some functions only TinyMUX has are not there.