Advertisement
Guest User

Untitled

a guest
May 20th, 2015
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Time On Ball
  3. // @version 0.4
  4. // @include http://*.koalabeast.com:*
  5. // @include http://*.jukejuice.com:*
  6. // @include http://*.newcompte.*
  7. // @author ballparts & Flail
  8. // ==/UserScript==
  9.  
  10.  
  11. ////////////////////////////
  12. // USER DEFINED VARIABLES //
  13. ////////////////////////////
  14.  
  15. // Color of text - can be hex value or color name (e.g., "white")
  16. var TEXT_COLOR = "white";
  17.  
  18. // Opacity of text - 0 is transparent, 1 is opaque
  19. var TEXT_OPACITY = 0.7;
  20.  
  21. // Size of the timer text font in pixels
  22. var TEXT_SIZE = 15;
  23.  
  24. // Whether to rotate with the player.
  25. var ROTATE = true;
  26.  
  27. ////////////////////////////////
  28. // END USER DEFINED VARIABLES //
  29. ////////////////////////////////
  30.  
  31. var TILE_SIZE = 40;
  32.  
  33. // Wait until the tagpro object exists, and add the function to tagpro.ready
  34. function addToTagproReady(fn) {
  35. // Make sure the tagpro object exists.
  36. if (typeof tagpro !== "undefined") {
  37. tagpro.ready(fn);
  38. } else {
  39. // If not ready, try again after a short delay.
  40. setTimeout(function() {
  41. addToTagproReady(fn);
  42. }, 0);
  43. }
  44. }
  45.  
  46. function waitForId(fn) {
  47. if (typeof tagpro !== "undefined" && tagpro.playerId && tagpro.players[tagpro.playerId].sprites) {
  48. fn();
  49. } else {
  50. setTimeout(function() {
  51. waitForId(fn);
  52. });
  53. }
  54. }
  55.  
  56. /**
  57. * Get text for overlaying on center of tiles.
  58. * @param {string} [color="#FFFFFF"] - The fill color to use for the text.
  59. * @return {PIXI.Text} - The created text.
  60. */
  61. function makeText() {
  62. var text = new PIXI.Text("00", {
  63. font: "bold " + TEXT_SIZE + "pt Arial",
  64. fill: TEXT_COLOR,
  65. stroke: "#000000",
  66. strokeThickness: 3,
  67. //alpha: TEXT_OPACITY,
  68. align: "center"
  69. });
  70. var anchor = {x: 0.5-0.5*(3/text.width), y: 0.5-0.5*(3/text.height)};
  71. text.anchor.x = anchor.x;
  72. text.anchor.y = anchor.y;
  73. text.x = text.y = 20;
  74. text.alpha = TEXT_OPACITY;
  75. text.visible = false;
  76. return text;
  77. }
  78.  
  79. addToTagproReady(function() {
  80. waitForId(function() {
  81. var text = makeText();
  82. console.log(tagpro.players[tagpro.playerId]);
  83. console.log(!!tagpro.players[tagpro.playerId].sprites);
  84. console.log(!!tagpro.players[tagpro.playerId].sprites.timer);
  85. var sprites = tagpro.players[tagpro.playerId].sprites;
  86. sprites.timer = text;
  87. sprites.ball.addChild(sprites.timer);
  88.  
  89.  
  90. var stdUpdate = tagpro.ui.update;
  91. tagpro.ui.update = function() {
  92. stdUpdate.apply(null, arguments);
  93. var millis = Math.max(0, tagpro.gameEndsAt - Date.now());
  94. var seconds = Math.floor((millis/1000))%60;
  95. if (seconds >= 0 && seconds <= 9) {
  96. seconds = '0' + seconds;
  97. }
  98. text.setText(seconds);
  99. if (ROTATE) {
  100. text.rotation = tagpro.players[tagpro.playerId].angle;
  101. }
  102. };
  103. });
  104. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement