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;- commas in one-argument functions, and the
space_compresssetting; - 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, 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.
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 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 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
Commas in one-argument functions
Section titled “Commas in one-argument functions”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
Spaces
Section titled “Spaces”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.
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.
mux_arguments
Section titled “mux_arguments”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.
mux_queue_functions
Section titled “mux_queue_functions”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.
mux_quiet
Section titled “mux_quiet”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.
mux_function_caller
Section titled “mux_function_caller”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.
protection_flags and attribute_eval_flags
Section titled “protection_flags and attribute_eval_flags”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.
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.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().- Mail drafts are not supported. TinyMUX’s
@mail <player>=<subject>opens a draft that-and~add to and--or@mail/sendsends; 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. Seehelp compatibility mail. - Some functions only TinyMUX has are not there.
pack()andunpack()are; see RhostMUSH Softcode for howunpack()treats a character that is not a digit.