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;
%mand%=<name>, two TinyMUX substitutions;- the
mux_logic,mux_justify,mux_collation,innermost_tokensandrhost_listsettings; - 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.
TinyMUX forms of shared functions
Section titled “TinyMUX forms of shared functions”These work on every game, with no setting:
| Call | Gives | PennMUSH gives |
|---|---|---|
switch(x,default) | default | an argument-count error |
add(5), mul(3) | 5, 3 | an argument-count error |
and(1), or(0), xor(1) | 1, 0, 1 | an argument-count error |
itext() | the innermost loop’s element, as itext(0) | an error |
lnum() | nothing | an 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()
Section titled “TinyMUX’s wrap()”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.
The set functions’ order
Section titled “The set functions’ order”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 and %=<name>
Section titled “%m and %=<name>”%m is TinyMUX’s name for the command being run, which is %c in PennMUSH and SharpMUSH. Both work.
think %m|%cOutput: 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=hellothink %=<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
The settings
Section titled “The settings”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.
mux_logic
Section titled “mux_logic”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.
mux_justify
Section titled “mux_justify”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.
mux_collation
Section titled “mux_collation”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.
innermost_tokens
Section titled “innermost_tokens”## 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.
rhost_list
Section titled “rhost_list”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.
What still needs rewriting
Section titled “What still needs rewriting”trim()takes its arguments in TinyMUX’s order whentiny_trim_funis 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’scolumns(<list>, <width>[, <delimiter>[, <indent>]])is a different function, so calls to it have to be rewritten, for example withtable()oralign().- Some functions only TinyMUX has are not there.