Fantastical Dice Set
A dice rolling set, that allows you to track the history of dice rolled, roll so only specific people can see the results, and so on.
Functions:
ansi(),
comp(),
die(),
edit(),
eq(),
gt(),
if(),
iter(),
lattr(),
lnum(),
name(),
not(),
oemit(),
pemit(),
pmatch(),
set(),
setq(),
strlen(),
switch(),
u(),
v().
Features:
regexp commands.
Instructions
Copy and paste the below code into a compatible MUSH or MUX.
MUSHCode for Fantastical Dice Set
@create Dice Set
@link Dice Set = #0
@lock/Basic Dice Set==me
@set Dice Set=!NO_COMMAND
@lset Dice Set/Basic=no_inherit
@set Dice Set = LINK_OK
@set Dice Set = VISUAL
&BLAH Dice Set=pemit(%#,You examined me!)
&CLEAR Dice Set=$clear dice:@wipe me/roll.*
&CMD.ROLL Dice Set=$^roll(|/me|/all|/[a-z]+) (|[0-9]+#|#)(|[0-9]+d|d)([0-9]+)$:think u(fun.roll,edit(%2,#,),edit(%3,d,),%4,%1)
@set Dice Set/CMD.ROLL=regexp
&DESCRIBE Dice Set=A large jumble of dice.%r%rRecent rollers:%r[iter(lattr(me/roll.all.*),%b%b[v(##)],%b,%r)]%r%rPrivate for you:%r[iter(lattr(me/roll.%#.*),%b%b[v(##)],%b,%r)]%r%r[ansi(h,use [name(me)])] for instructions.%r
@set Dice Set/DESCRIBE=no_command visual public nearby
&FUN.ROLL Dice Set=u(h.roll,if(eq(strlen(%0),0),1,%0),if(eq(strlen(%1),0),1,%1),%2,if(gt(strlen(%3),0),edit(%3,/,),all))
&H.ROLL Dice Set=setq(0,iter(lnum(%0),die(%1,%2)))[setq(1,%0-%1d%2: %q0)][switch(%3,me,pemit(%#,Dice: \[To yourself\] You roll %q1.)[set(me,roll.%#.%#:You rolled %q1)],all,set(me,roll.all.%#:%N rolled %q1)[pemit(%#,Dice: You roll %q1.)][oemit(%#,Dice: %N rolls %q1.)],if(not(comp(pmatch(%3),#-1)),pemit(%#,Dice: I don't see %3),pemit(%#,Dice: \[To [name(pmatch(%3))]\] You roll %q1.)][pemit(pmatch(%3),Dice: \[To you\] %N rolls %q1.)][set(me,roll.[pmatch(%3)].%#:%N rolled %q1)][set(me,roll.%#.%#:You rolled: %q1)])]
&ROLL.#1559.#6061 Dice Set=Walker rolled 1-1d20: 19
&ROLL.#6061.#6061 Dice Set=You rolled: 1-1d20: 19
&ROLL.#8907.#8907 Dice Set=You rolled 1-3d20: 9
&ROLL.#9759.#9759 Dice Set=You rolled 6-3d6: 9 6 5 13 5 14
&ROLL.ALL.#1622 Dice Set=Raevnos rolled 1-2d20: 27
&ROLL.ALL.#6061 Dice Set=Walker rolled 2-1d20: 12 15
&ROLL.ALL.#8907 Dice Set=Sonya rolled 1-2d20: 18
&ROLL.ALL.#9759 Dice Set=Kevin rolled 6-3d6: 7 15 7 13 10 15
&TYPE Dice Set=obsolete
&USE Dice Set=Fantastical Dice Set%r%b%bPast rolls are stored on the dice. review them with [ansi(h,look [name(me)])]%r[ansi(h,clear dice)] to clear the record.%r[ansi(h,roll <sides>)] = roll one <sides> sided dice.%r[ansi(h,roll <times>d<sides>)] - roll <times> <sides> sided dice.%r[ansi(h,roll <count>#<times>d<sides>)] - roll <times> <sides> sided dice <count> times.%r%rDirectional rolling:%r[ansi(h,roll/all)] - default, roll for everyone to see.%r[ansi(h,roll/me)] - roll so only you can see it.%r[ansi(h,roll/<name>)] - Roll so only you and <name> can see it.%r%rExamples:%r%b%b to roll 2d20: [ansi(h,roll 2d20)].%r%b%bTo roll ability scores: [ansi(h,roll 6#3d6)]%r%b%bRoll a d20 for Walker: roll/walker 20%r
@set Dice Set/USE=no_command
use Dice Set
@link Dice Set = #0
@lock/Basic Dice Set==me
@set Dice Set=!NO_COMMAND
@lset Dice Set/Basic=no_inherit
@set Dice Set = LINK_OK
@set Dice Set = VISUAL
&BLAH Dice Set=pemit(%#,You examined me!)
&CLEAR Dice Set=$clear dice:@wipe me/roll.*
&CMD.ROLL Dice Set=$^roll(|/me|/all|/[a-z]+) (|[0-9]+#|#)(|[0-9]+d|d)([0-9]+)$:think u(fun.roll,edit(%2,#,),edit(%3,d,),%4,%1)
@set Dice Set/CMD.ROLL=regexp
&DESCRIBE Dice Set=A large jumble of dice.%r%rRecent rollers:%r[iter(lattr(me/roll.all.*),%b%b[v(##)],%b,%r)]%r%rPrivate for you:%r[iter(lattr(me/roll.%#.*),%b%b[v(##)],%b,%r)]%r%r[ansi(h,use [name(me)])] for instructions.%r
@set Dice Set/DESCRIBE=no_command visual public nearby
&FUN.ROLL Dice Set=u(h.roll,if(eq(strlen(%0),0),1,%0),if(eq(strlen(%1),0),1,%1),%2,if(gt(strlen(%3),0),edit(%3,/,),all))
&H.ROLL Dice Set=setq(0,iter(lnum(%0),die(%1,%2)))[setq(1,%0-%1d%2: %q0)][switch(%3,me,pemit(%#,Dice: \[To yourself\] You roll %q1.)[set(me,roll.%#.%#:You rolled %q1)],all,set(me,roll.all.%#:%N rolled %q1)[pemit(%#,Dice: You roll %q1.)][oemit(%#,Dice: %N rolls %q1.)],if(not(comp(pmatch(%3),#-1)),pemit(%#,Dice: I don't see %3),pemit(%#,Dice: \[To [name(pmatch(%3))]\] You roll %q1.)][pemit(pmatch(%3),Dice: \[To you\] %N rolls %q1.)][set(me,roll.[pmatch(%3)].%#:%N rolled %q1)][set(me,roll.%#.%#:You rolled: %q1)])]
&ROLL.#1559.#6061 Dice Set=Walker rolled 1-1d20: 19
&ROLL.#6061.#6061 Dice Set=You rolled: 1-1d20: 19
&ROLL.#8907.#8907 Dice Set=You rolled 1-3d20: 9
&ROLL.#9759.#9759 Dice Set=You rolled 6-3d6: 9 6 5 13 5 14
&ROLL.ALL.#1622 Dice Set=Raevnos rolled 1-2d20: 27
&ROLL.ALL.#6061 Dice Set=Walker rolled 2-1d20: 12 15
&ROLL.ALL.#8907 Dice Set=Sonya rolled 1-2d20: 18
&ROLL.ALL.#9759 Dice Set=Kevin rolled 6-3d6: 7 15 7 13 10 15
&TYPE Dice Set=obsolete
&USE Dice Set=Fantastical Dice Set%r%b%bPast rolls are stored on the dice. review them with [ansi(h,look [name(me)])]%r[ansi(h,clear dice)] to clear the record.%r[ansi(h,roll <sides>)] = roll one <sides> sided dice.%r[ansi(h,roll <times>d<sides>)] - roll <times> <sides> sided dice.%r[ansi(h,roll <count>#<times>d<sides>)] - roll <times> <sides> sided dice <count> times.%r%rDirectional rolling:%r[ansi(h,roll/all)] - default, roll for everyone to see.%r[ansi(h,roll/me)] - roll so only you can see it.%r[ansi(h,roll/<name>)] - Roll so only you and <name> can see it.%r%rExamples:%r%b%b to roll 2d20: [ansi(h,roll 2d20)].%r%b%bTo roll ability scores: [ansi(h,roll 6#3d6)]%r%b%bRoll a d20 for Walker: roll/walker 20%r
@set Dice Set/USE=no_command
use Dice Set