Jumble Functions

Two versions of a function that replaces <percent> of the words in <list> with random words from <new words>.

Author: Raevnos
Category: Functions
Commands: @create, @lock, @set.


Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Jumble Functions

@create Jumbles
@lock Jumbles==me
&COMBINE Jumbles=%0 %1%b
&DESCRIBE Jumbles=Two functions.%r%ru([num(me)]/jumble, list, percent, new words). Replaces <percent> of the words in <list> with random words from <new words>. Takes 9 + 2*words(<list>) function calls. %r%ru([num(me)]/jumble2, list, percent, new words). Does the same thing, but it alternates real words and jumbled words, though the real words are chosen at random and are in the same order as they appear in the original list. Takes 17 function calls.
@set Jumbles/DESCRIBE=no_command visual public nearby
&JUMBLE Jumbles=setq(0, %1)[splice(map(mixup, %0), extract(shuffle(repeat(%2%b, setr(1, words(%0)))), 1, %q1), HOPENOBODYSAYSTHIS)]
@set Jumbles/JUMBLE=visual
&JUMBLE2 Jumbles=squish(mix(combine, elements(%0, sort(extract(shuffle(lnum(1, setr(0, words(%0)))), 1, setr(1, floor(mul(%q0, fdiv(%1, 100))))))), extract(shuffle(repeat(%2%b, %q0)), 1, %q1)))
&MIXUP Jumbles=switch(rand(100), <%q0, HOPENOBODYSAYSTHIS, %0)
@set Jumbles/MIXUP=visual

look Jumbles