Created
September 28, 2016 04:55
-
-
Save AlbinoDrought/16edc0fd7176a1b657e90ca2f5b58d99 to your computer and use it in GitHub Desktop.
Turns a number (0 <= i <= 52) into a hackmud-compatible color code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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