Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Time On Ball
- // @version 0.4
- // @include http://*.koalabeast.com:*
- // @include http://*.jukejuice.com:*
- // @include http://*.newcompte.*
- // @author ballparts & Flail
- // ==/UserScript==
- ////////////////////////////
- // USER DEFINED VARIABLES //
- ////////////////////////////
- // Color of text - can be hex value or color name (e.g., "white")
- var TEXT_COLOR = "white";
- // Opacity of text - 0 is transparent, 1 is opaque
- var TEXT_OPACITY = 0.7;
- // Size of the timer text font in pixels
- var TEXT_SIZE = 15;
- // Whether to rotate with the player.
- var ROTATE = true;
- ////////////////////////////////
- // END USER DEFINED VARIABLES //
- ////////////////////////////////
- var TILE_SIZE = 40;
- // Wait until the tagpro object exists, and add the function to tagpro.ready
- function addToTagproReady(fn) {
- // Make sure the tagpro object exists.
- if (typeof tagpro !== "undefined") {
- tagpro.ready(fn);
- } else {
- // If not ready, try again after a short delay.
- setTimeout(function() {
- addToTagproReady(fn);
- }, 0);
- }
- }
- function waitForId(fn) {
- if (typeof tagpro !== "undefined" && tagpro.playerId && tagpro.players[tagpro.playerId].sprites) {
- fn();
- } else {
- setTimeout(function() {
- waitForId(fn);
- });
- }
- }
- /**
- * Get text for overlaying on center of tiles.
- * @param {string} [color="#FFFFFF"] - The fill color to use for the text.
- * @return {PIXI.Text} - The created text.
- */
- function makeText() {
- var text = new PIXI.Text("00", {
- font: "bold " + TEXT_SIZE + "pt Arial",
- fill: TEXT_COLOR,
- stroke: "#000000",
- strokeThickness: 3,
- //alpha: TEXT_OPACITY,
- align: "center"
- });
- var anchor = {x: 0.5-0.5*(3/text.width), y: 0.5-0.5*(3/text.height)};
- text.anchor.x = anchor.x;
- text.anchor.y = anchor.y;
- text.x = text.y = 20;
- text.alpha = TEXT_OPACITY;
- text.visible = false;
- return text;
- }
- addToTagproReady(function() {
- waitForId(function() {
- var text = makeText();
- console.log(tagpro.players[tagpro.playerId]);
- console.log(!!tagpro.players[tagpro.playerId].sprites);
- console.log(!!tagpro.players[tagpro.playerId].sprites.timer);
- var sprites = tagpro.players[tagpro.playerId].sprites;
- sprites.timer = text;
- sprites.ball.addChild(sprites.timer);
- var stdUpdate = tagpro.ui.update;
- tagpro.ui.update = function() {
- stdUpdate.apply(null, arguments);
- var millis = Math.max(0, tagpro.gameEndsAt - Date.now());
- var seconds = Math.floor((millis/1000))%60;
- if (seconds >= 0 && seconds <= 9) {
- seconds = '0' + seconds;
- }
- text.setText(seconds);
- if (ROTATE) {
- text.rotation = tagpro.players[tagpro.playerId].angle;
- }
- };
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement