Last active
December 20, 2015 04:44
Tagpro Userscript: Get confused between someballs because of similar names? Well now you can can change their names OR change the colors of their names!
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
// ==UserScript== | |
// @name SomeBall Name Changer | |
// @namespace https://www.reddit.com/user/RealDuckBill/ | |
// @version 1.0 | |
// @description Change the names - or colors - of someballs in-game. | |
// @author RealDuck | |
// @include http://tagpro-*.koalabeast.com:* | |
// @include http://tangent.jukejuice.com:* | |
// @grant none | |
// ==/UserScript== | |
tagpro.ready(function() { | |
//-- USER OPTIONS --// | |
//If you want to change someball colors instead of names, change "false" to "true". | |
var colorChangeMode = false; | |
//If in color mode, add or change the colors here. | |
//Go to: http://www.w3schools.com/tags/ref_colorpicker.asp for specific color codes. | |
//Remember that the color must be in quotation marks, must have a comma before it, and that the last item isn't followed by a comma. | |
var colorArray = ['#ff99cc', '#33ccff', '#ff6600', '#cc99ff', '#66ff99', '#e60000', '#cccc00', '#ff0066']; | |
//If in name changer mode, change or add more prefixes (maximum length is 5 characters each). | |
//Use same syntax as specified for adding more colors. | |
var namePrefixes = ['Ugly', 'Short', 'Tall', 'Hairy', 'Fat', 'Scary', 'Nice', 'Mean', 'Rude', 'Old']; | |
//Change or add random name suffixes. | |
//Use same syntax, maximum character lenth for each word is 6. | |
var nameSuffixes = ['Duck', 'Cat', 'Kid', 'Man', 'Ball', 'Dog', 'Xile', 'Crow', 'Boy', 'Lady']; | |
//-- END OF USER OPTIONS --// | |
//Genarates a random username based on prefixes and suffixes. | |
function randomUsername() { | |
//Get random prefix and suffix. | |
var prefix = namePrefixes[Math.floor(Math.random() * namePrefixes.length)]; | |
var suffix = nameSuffixes[Math.floor(Math.random() * nameSuffixes.length)]; | |
//Remove them from arrays to avoid repeats. | |
namePrefixes.splice(namePrefixes.indexOf(prefix), 1); | |
nameSuffixes.splice(nameSuffixes.indexOf(suffix), 1); | |
//Return full name. | |
return prefix + " " + suffix; | |
} | |
//Function checks if name is just a normal someball, not something like "Some Ball X". | |
function checkName(playerName) { | |
if(playerName.indexOf("Some Ball") === 0) { | |
if(playerName.length === 9) return true; | |
for(var i = 1; i <= 9; i++) { | |
if(playerName[9] === " " && parseInt(playerName[10]) === i) return true; | |
} | |
} | |
return false; | |
} | |
//Seperate functions for color mode or normal name changing mode. | |
if(colorChangeMode) { | |
//Rewrite tagpro draw name renderer which runs whenever a player joins. | |
tagpro.renderer.drawName = function(player, t) { | |
//Unaltered original parts of the function. | |
if (!player.sprites.name || t) { | |
player.sprites.name && player.sprites.info.removeChild(player.sprites.name); | |
if (!tagpro.settings.ui.names) return; | |
//r represents final color of name. | |
var r = player.auth ? "#BFFF00" : "#ffffff"; | |
//If the playe's name has some ball and is not registered, change the color to the first one from the color array. | |
if(checkName(player.name) && !player.auth) { | |
r = colorArray[0]; | |
//removes it to avoid repeated colors. | |
colorArray.splice(0, 1); | |
} | |
//Other unaltered parts of the original code. | |
player.sprites.name = tagpro.renderer.veryPrettyText(player.name, r), player.sprites.info.addChild(player.sprites.name); | |
} | |
player.sprites.name.x = 20, player.sprites.name.y = -21, player.sprites.name.visible = tagpro.settings.ui.names ? !0 : !1 | |
}; | |
} else { | |
tagpro.renderer.drawName = function(player, t) { | |
if (!player.sprites.name || t) { | |
player.sprites.name && player.sprites.info.removeChild(player.sprites.name); | |
if (!tagpro.settings.ui.names) return; | |
var r = player.auth ? "#BFFF00" : "#ffffff"; | |
if(checkName(player.name) && !player.auth) { | |
//Generate a random username and set it to be this player's name (will also appear on scoreboard etc.). | |
var randomName = randomUsername(); | |
player.sprites.name = tagpro.renderer.veryPrettyText(randomName, r); | |
player.name = randomName; | |
} else { | |
player.sprites.name = tagpro.renderer.veryPrettyText(player.name, r); | |
} | |
player.sprites.info.addChild(player.sprites.name); | |
} | |
player.sprites.name.x = 20, player.sprites.name.y = -21, player.sprites.name.visible = tagpro.settings.ui.names ? !0 : !1 | |
}; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment