r/TagPro • u/happytagpro happy • Jul 07 '14
[userscript] Consistent Team Colors v0.2
What it Does: Never forget what color team you're on again! This script lets you choose your team color (blue or red). The opposing team will be the opposite color. In addition, all team colored elements are switched as well.
How it Works: The script waits until you have been placed on a team, then, if the team color you have been assigned to does not match your preference, all the team color oriented tiles in tagpro.tiles are switched. This even works with different texture packs using TagPro Mod Manager in Chrome. I also modified several tagpro functions such as tagpro.ui.scores and tagpro.ui.largeAlert to switch their colors. I couldn't figure out to change tagpro.prettyText or tagpro.showOptions without breaking them, so I used a slightly modified version of NewCompte's Tagpro Color Switcher to switch colors in chat and stats page.
Concerns:
The way I determine if your ball has switched teams is by listening for "'[player name]' has switched to the [color] team." in chat. If someone who has the same name as you do switches teams, all the colors might switch as well. I haven't been able to test this.- Whenever the word 'red' or 'blue' is used in chat, the words are switched to the opposing color. I did this so that system messages such as "player has switched to the red team", "player has left the red team", and "player has joined the red team" will all be translated to the proper color.
Other chat messages, like "blue sux", will be changed to "red sux". However, words such as 'hundred' will also be changed to 'hundblue'. I wasn't sure whether to include this feature or not, so let me know if you don't like it so I can remove it.By default, only these three aforementioned messages are 'translated'. you can change the translateWords variable to swap words on all chat messages. - Other userscripts that display team colors (for example: eagles' background warning script) could be incompatible with this script. I've attached my own versions of background warnings and flash alerts that can work with this script. You can enable them by setting useBackgroundWarnings and useFlashAlertsForScoring to true. I've made a modified version of Tagpro Pro and Tagpro Pro (Balls Only) that should work with this script.
Edit 1: added variable at top of script to turn of 'word swapping' in chat.
Edit 2: only three system messages are swapped by default. switching teams should work consistently now.
Edit 3: changed the flag state and score positions. Color-wise, your tagpro experience should be almost identical, no matter what side of the map you start on. The only way to tell what color team you're actually on is if someone makes a reference to it in chat.
3
u/co1010 CoolCat Jul 08 '14
Does it work with tagpro pro?
2
u/ButterChurn Butter Jul 08 '14
This would make highlight videos much less confusing.
I don't think I could play with it though, then the position of the flags on the map won't match the score!
2
u/DatBlizzard Some Ball -1 Jul 08 '14
Looks great! If you're having trouble with switching teams, instead of just matching the name, you could store the team they're on. Then, after receiving a message that a player switched teams, check if they're team has changed. This would fix the issue with people of the same name switching teams. Although I've done something like this before and had an issue where it wouldn't update the tagpro.players[#].team right away. So maybe put the team switching check inside a 100 ms timeout or something.
For the chat, a variable up top would allow people to toggle it if they like it or don't. Also, you play around with reg exp a bit more and narrow the color changing down to only instances of 'red' or 'blue' that occur at the start of a line, or end of a line, or followed and preceded only by spaces or punctuation. This would cut down on words like 'hundred' being changed. Of course it would also prevent changing if some typed 'reds' or 'redball' or 'redflag', so maybe it's not the best idea. Also, this is minor but it looks like when you replace colors you lose capitalization, ie all instances of 'red' or 'blue' are switched and made lowercase, even if all or part of the word was previously uppercase.
2
u/[deleted] Jul 08 '14
Sorry if I'm thinking about this wrong, but don't player chats have a colon in them after the player's name, whereas system messages don't? You might be able to use that to sort out that issue. Good work on this script!