Skip to content

Instantly share code, notes, and snippets.

@AlbinoDrought
Created September 28, 2016 04:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlbinoDrought/16edc0fd7176a1b657e90ca2f5b58d99 to your computer and use it in GitHub Desktop.
Save AlbinoDrought/16edc0fd7176a1b657e90ca2f5b58d99 to your computer and use it in GitHub Desktop.
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