Muxify (MU code editor)
-
So I have an online editor for MU code that I've added to the menu (the document icon with the hover text Muxify). This will bring you to the editor in a new tab.
Usage:
def <alias> { <code> } - Simple preprocessor for code repetition or object replacement.
Ex:def roller { #36 }
def alert { [ansi(hr, |, hw, %o, hr, |)] }
To use in code wrap the def in colons:
&f.function :roller:=pemit(%1, :alert:)
Which will result in:
&f.function #36=pemit(%1, [ansi(hr, |, hw, %o, hr, |)])
Commenting - Use // before any comments to have them parsed when minified. Everything after // is commented out, so make sure no code follows it. Block commenting is also available as /* <multiline comments> */
Ex:// set initial total value [setq(t, ladd(%qf))] // here is okay too
or
/* this is a multiline comment */
Keyboard Shortcuts - Supported, see the ACE editor list
Storage - Code can be saved locally or loaded in minified or expanded form.
Minification - As you code, the minified version will be filled in simultaneously. It should cover most cases to proper format.
Explode - This will take minified code and add whitespace to it in the left pane.
Finally, here is some example code you can copy/paste to the left pane to test it out:
/* Requires global function pluck: * [setq(i, if(t(%2), %2, %b))][setq(o, if(t(%3), %3, %b))][extract(%0, match(%0, %1*, %qi), 1, %qi, %qo)] * * Requires global function alert: * [ansi(hr, |, hw, %b%0%b, hr, |)] * * For english stats, a fate stat object is needed, defined here with fss, * with the following format &d.skills fss=skill|skill|skill */ def fr { #36 // set to object dbref } def fss { #75 // dbref for stat system } &c.roll :fr:=$+roll *:ulocal(%!/f.parse, %#, %0) &f.parse :fr:= // preformat roll string [setq(s, edit(%1, %b, , +, %b))] // set error register [setq(e,)] // set natural language register [setq(l,)] // fate dice [setq(f, lrand(-1, 1, 4))] // set initial total value [setq(t, ladd(%qf))] /* check if string token is a word and parse it, otherwise assume * it is a number and add to total */ [iter( %qs, if(isword(%i0), setq(t, ladd(%qt [u(%!/f.get-dice, %0, %i0)])), [setq(t, add(%qt, %i0))] [setq(l, %ql|%i0)] ) )] // if error(s), display them, otherwise display successful roll [if( t(%qe), u(%!/f.display.error, %0, trim(%qe, , |)), u(%!/f.display.roll, %0, trim(%ql, , |), %qt, %qf) )] &f.get-dice :fr:= /* get the skill from the stat object (used for default cases where the * skill exists but is not present on charbit) */ [setq( 0, pluck( get(%va/d.skills), %1, |))] [if( t(%q0), // get skill value from charbit or return 0 [setq( 1, pluck( get(%0/_skills), %q0, |))] [if( t(%q1), trim(rest(%q1, :)), 0 )] // add to the language output [setq( l, %ql|[if(t(%q1), %q1, %q0)])], // or add as an error setq(e, %qe|could not find '%1'.) )] &f.display.roll :fr:= // send roll message to room remit(loc(%0), [alert(+roll)]%b[name(%0)] rolls [u(%!/f.tr.dice, %3)] + [iter(%1, if(t(rest(%i0,:)), [first(%i0,:)] %(+[rest(%i0,:)]%), %i0), |, %b+%b)] for a[case(%qt,1,n,7,n)] [ansi(hw,[u(%!/f.tr.success, %qt)] %([if(gte(%qt,0), +%qt, %qt)]%))].)] ) &f.tr.dice :fr:= // make fate dice pretty edit(%0, -1, ansi(y, %[, hw, -, y, %]), 0, ansi(y, %[, hw, %b, y, %]), 1, ansi(y, %[, hw, +, y, %])) &f.tr.success :fr:= // provide english language values case(%0, -2, Terrible, -1, Poor, 0, Mediocre, 1, Average, 2, Fair, 3, Good, 4, Great, 5, Superb, 6, Fantastic, 7, Epic, 8, Legendary, Mythic) &f.display.error :fr:= // display any errors to roller pemit(%0, [alert(+roll)] Errors: [itemize(%1, |)]) /* set the data object for skills list. Alternatively add a d.skills * attribute to the roller and edit f.get-dice to use %! instead of %va */ @va :fr:=:fss:
-
I like the 'Explode' button. It makes me hesitate for the tiniest moment every time I'm just about to click, like I'm about to release some kind of doomsday curse on the world.
Now I just need to convince some poor fool to let me tinker with their MU* again.
-
@HelloRaptor said:
I'm about to release some kind of doomsday curse on the world.
This is essentially what MUX code is. It's an eldritch horror that warps the mind of any who know it. ^.^
-
@Cobaltasaurus , yeah, I was thinking that even as I typed it. ^_^
-
Request:
/* this is a comment block that blocks comments all the way down. */
Please support comment blocks! Thanks!
-
// single line def fs { fate sheet // in line } /*block test comments*/ /* block comments added just for @Thenomain */ &c.sheet :fs:= $+sheet*: ulocal( %!/f.parse, %#, %0 )
-
Returns for me:
/* block comments added just for @Thenomain */ &c.sheet fate sheet=$+sheet*: ulocal( %!/f.parse, %#, %0 )
I'm already starting to change my commenting style for this.
-
@Thenomain The @ symbol broke it. I'll look into why, but for now it should work as long as @ isn't in there.
-
@Thenomain Okay, my crappy regex is better now, so everything should be working as expected.
-
Multi-line comments containing ====== and, I presume, () also aren't getting processed. I haven't checked ------- or :, either; after noticing the first two I felt that I could or should leave it up to that for now. I tend to header new sections via:
== This is a new section ============================================= -- this is a single chunk of code ------------------------------------ followed by some comments about what is going on 0: input r: register
This is why I wanted
/* multi-line block comments */
. No guarantee that I won't put swaths of code in there. -
I just tried this:
// single line def fs { fate sheet // in line } /*block test comments*/ /* block comments added just for @ Thenomain */ /* == This is a new section ============================================= -- this is a single chunk of code ------------------------------------ followed by some comments about what is going on 0: input r: register */ &c.sheet :fs:= $+sheet*: ulocal( %!/f.parse, %#, %0 )
and my output was this:
&c.sheet fate sheet=$+sheet*: ulocal( %!/f.parse, %#, %0 )
-
This is what I get for not knowing to reload while something's being fixed. Other things are fixed as well, working with @Glitch. I thus decree that this system doth Kick Mightily Ass.
-
Yeah, this is pretty goddamn awesome. @Glitch
-
Revive!
Hey @Glitch, any chance you can diagnose why this isn't working fro me?
Input:
&f.auto.beats.weekly xpas= case( u( f.current_period, %0 ), 0, 0, 1, 10, 2, 5, 3, 3, 1 )
Output:
&f.auto.beats.weekly xpas= case( u( f.current_period, %0 ), 0, 0, 1, 10, 2, 5, 3, 3, 1 )
I would expect this output as a single line, to be inserted into the MUX.
-
As a note, this line comes from here:
https://github.com/thenomain/GMCCG/blob/master/4 - XP and Costs/4c - XP and Advancement.txt#L2051
Mind you, when I copy/paste it, it works fine.
-
@skew Hey, so when I copy and paste that line, I get the same expected results as @Thenomain, so I'm not sure. Did you copy and paste just that line? Or was it part of more? Or did you type it in yourself?
-
When I copy and paste that text into something like gedit and make sure every new line is \n, Muxify correctly adjusts the output to a single line.
When I CTRL+H \n -> \r, the output looks just like the input (i.e., not a single line).
-
@Glitch I select the text exactly as it appears in my post above, just mouse over, highlight, then ctrl+c. I go to muxify, click in the left box, and hit ctrl+v. The left window matches the right.
I'm on Win10, using Chrome (though tried on Edge, too, just for fun).
And sorry if this is overly detailed, just trying to be thorough.
-
Update! I just installed Firefox, and it works as expected.
I'll just go forward with this. Thanks!
-
Works fine in Vivaldi and Chrome on the Mac.
(note to @Glitch, can you look into resolving my 'not really a bug' about when I use
*/*
inside code? thanks.)