Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Turns a number (0 <= i <= 52) into a hackmud-compatible color code.
/*
Using color codes:
`0message`
`1message`
`amessage`
`Amessage`
The game matches the following regex:
`(?:([0-9])|([a-z])|([A-Z]))(.+?)`
*/
function(context, args) {
function gcolor(i) {
var max = 53; // exclusive
if(i < 0) i = 0;
i = i % max;
var even = i % 2 == 0,
o = 0,
off = '';
if(even) {
// lowercase
o = i / 2;
off = 'a';
} else {
// uppercase
o = (i - 1) / 2;
off = 'A';
}
return String.fromCharCode(off.charCodeAt(0) + o);
};
var msg = "";
var body = " `0crash override`\n";
for(var i = 0; i < args.belly; i++) {
var color = gcolor(i);
msg += body.replace("0", color);
}
#s.chats.send({channel: "0000", msg: msg});
#s.accts.xfer_gc_to({ to: "albinodrought", amount: "1GC" }); // :)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment