mojo_client/bin/scripts/toleet.def
False.Genesis a3ae8273ba * auto-load all .def files in ./scripts/ directory after executing _startup.def
* fixed exception at DefScript:substr when called with empty string
* added 3 new functions: uppercase, lowercase, random[,<min>] <max>.
* added some better debug output when an incorrect script is loaded
2007-04-02 22:41:33 +00:00

96 lines
1.7 KiB
Modula-2

// toleet.def
// ==========
// purpose: convert any text into leetspeak [1337sp34k]
// args:
// @def: the text to convert
// returns: leetspeak^^
// call it from script only
#permission=255
#onload
// this can be used by other scripts to check if we have loaded this script
set,#HAVE_LEET true
#endonload
// --- Begin of main function ---
// empty the string where the leet will be stored
set,str
// total length of the string to convert
set,l ?{strlen ${@def}}
// position counter
set,x 0
loop
// check if we have reached the end of the string
if ?{bigger,${x} ${l}}
exitloop
endif
// c stores current char (@def at position x); c2 is the same char but always lowercased
set,c ?{substr,1,${x} ${@def}}
set,c2 ?{lowercase ${c}}
// conversion functions:
// note that "+" is a variable name here!
// it will store the "new" char if c/c2 could be converted
if ?{equal,${c2} a}
set,+ 4
endif
if ?{equal,${c2} e}
set,+ 3
endif
if ?{equal,${c2} i}
set,+ !
endif
if ?{equal,${c2} l}
set,+ 1
endif
if ?{equal,${c2} t}
set,+ 7
endif
if ?{equal,${c2} s}
set,+ 5
endif
if ?{equal,${c2} o}
set,+ 0
endif
if ?{equal,${c2} f}
set,+ ph
endif
if ?{equal,${c2} h}
set,+ #
endif
if ?{equal,${c} Z}
set,+ 7
endif
if ?{equal,${c} R}
set,+ 2
endif
if ?{equal,${c} B}
set,+ <3
endif
// if var "+" is still empty, default it to our current char
default,+ ${c}
// and append it to the final output
append,str ${+}
// finally delete it again
unset +
// and increase the counter by 1
add,x 1
endloop
unset l
unset x
unset c
unset c2
return ${str}