Button Puzzle (Updated Version)
Instructions
Copy and paste the below code into a compatible MUSH or MUX.
MUSHCode for Button Puzzle (Updated Version)
@create Button Puzzle
@lock Button Puzzle==me
@set Button Puzzle=!NO_COMMAND
&BUTTON Button Puzzle=ansi(r(%0),\,-.%r|%0|`-')
&BUTTONS Button Puzzle=align(3 3 3,u(button,%0),u(button,%1),u(button,%2),%b,,%r)
&BYTE Button Puzzle=r
&COLORONE Button Puzzle=B
&COLORTWO Button Puzzle=R
&DESCRIBE Button Puzzle=A three-by-three square of buttons. Try '[ANSI(hw,press)]'ing a number.
@set Button Puzzle/DESCRIBE=no_command visual prefixmatch public nearby
&DISPLAY Button Puzzle=null(map(#lambda/setq(\%0,ifelse(band([baseconv(v(byte),36,10)],shl(1,dec(\%1))),[v(colorone)],[v(colortwo)])),1 2 3 4 5 6 7 8 9))[step(buttons,1 2 3 4 5 6 7 8 9,3,%b,%r)]
&DONE Button Puzzle=$BP/done:@break v(byte);@pemit %#=Not quite done!
&KEY Button Puzzle=lmath(add,map(#lambda/shl(1,\%0),map(#lambda/dec(\%0),%0)))
&PRESS Button Puzzle=$Press ?:&byte me=[baseconv(bxor(baseconv(v(byte),36,10),u(key,v(touch`%0))),10,36)];@pemit %#=%r[u(display)]
&TOUCH Button Puzzle=@@(This tree branch holds which keys touch others)
@set Button Puzzle/TOUCH=no_command
&TOUCH`1 Button Puzzle=1 2 4
&TOUCH`2 Button Puzzle=1 2 3 5
&TOUCH`3 Button Puzzle=2 3 6
&TOUCH`4 Button Puzzle=1 4 5 7
&TOUCH`5 Button Puzzle=2 4 5 6 8
&TOUCH`6 Button Puzzle=3 5 6 9
&TOUCH`7 Button Puzzle=4 7 8
&TOUCH`8 Button Puzzle=5 7 8 9
&TOUCH`9 Button Puzzle=6 8 9
look Button Puzzle
@lock Button Puzzle==me
@set Button Puzzle=!NO_COMMAND
&BUTTON Button Puzzle=ansi(r(%0),\,-.%r|%0|`-')
&BUTTONS Button Puzzle=align(3 3 3,u(button,%0),u(button,%1),u(button,%2),%b,,%r)
&BYTE Button Puzzle=r
&COLORONE Button Puzzle=B
&COLORTWO Button Puzzle=R
&DESCRIBE Button Puzzle=A three-by-three square of buttons. Try '[ANSI(hw,press)]'ing a number.
@set Button Puzzle/DESCRIBE=no_command visual prefixmatch public nearby
&DISPLAY Button Puzzle=null(map(#lambda/setq(\%0,ifelse(band([baseconv(v(byte),36,10)],shl(1,dec(\%1))),[v(colorone)],[v(colortwo)])),1 2 3 4 5 6 7 8 9))[step(buttons,1 2 3 4 5 6 7 8 9,3,%b,%r)]
&DONE Button Puzzle=$BP/done:@break v(byte);@pemit %#=Not quite done!
&KEY Button Puzzle=lmath(add,map(#lambda/shl(1,\%0),map(#lambda/dec(\%0),%0)))
&PRESS Button Puzzle=$Press ?:&byte me=[baseconv(bxor(baseconv(v(byte),36,10),u(key,v(touch`%0))),10,36)];@pemit %#=%r[u(display)]
&TOUCH Button Puzzle=@@(This tree branch holds which keys touch others)
@set Button Puzzle/TOUCH=no_command
&TOUCH`1 Button Puzzle=1 2 4
&TOUCH`2 Button Puzzle=1 2 3 5
&TOUCH`3 Button Puzzle=2 3 6
&TOUCH`4 Button Puzzle=1 4 5 7
&TOUCH`5 Button Puzzle=2 4 5 6 8
&TOUCH`6 Button Puzzle=3 5 6 9
&TOUCH`7 Button Puzzle=4 7 8
&TOUCH`8 Button Puzzle=5 7 8 9
&TOUCH`9 Button Puzzle=6 8 9
look Button Puzzle