Arbybear

TagPro Milliseconds

Jul 15th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. // ==UserScript==
  2. // @name TagPro Milliseconds
  3. // @version 2.2.3
  4. // @description Display tenths of seconds on the tagpro clock and add outlines to the score
  5. // @include http://tagpro-*.koalabeast.com:*
  6. // @include http://tangent.jukejuice.com:*
  7. // @include http://*.newcompte.fr:*
  8. // @author Some Ball -1
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. tagpro.ready(function() {
  13.  
  14. var startTime = 15; //time in seconds to begin showing fractional seconds, set to 0 to turn off
  15. var scoreStroke = true; //true or false, whether or not to show score outline
  16. //////////////////////////////////////////////////////////////////////////
  17.  
  18. var end = false;
  19. function outlineScore()
  20. {
  21. if(tagpro.renderer.layers.ui.children.length>1) //timer put in first so >1
  22. {
  23. tagpro.renderer.layers.ui.removeChild(tagpro.ui.sprites.redScore)
  24. tagpro.renderer.layers.ui.removeChild(tagpro.ui.sprites.blueScore)
  25. }
  26. tagpro.ui.sprites.redScore = new PIXI.Text(tagpro.score.r ? tagpro.score.r.toString() : "0", {
  27. fill: "#FF0000",
  28. stroke: "black",
  29. strokeThickness: scoreStroke*3,
  30. font: "bold 40pt Arial"
  31. }), tagpro.ui.sprites.blueScore = new PIXI.Text(tagpro.score.b ? tagpro.score.b.toString() : "0", {
  32. fill: "#0000FF",
  33. stroke: "black",
  34. strokeThickness: scoreStroke*3,
  35. font: "bold 40pt Arial"
  36. });
  37. tagpro.ui.sprites.redScore.alpha = .5, tagpro.ui.sprites.blueScore.alpha = .5, tagpro.ui.sprites.redScore.anchor.x = 1, tagpro.ui.sprites.blueScore.anchor.x = 0, tagpro.renderer.layers.ui.addChild(tagpro.ui.sprites.redScore), tagpro.renderer.layers.ui.addChild(tagpro.ui.sprites.blueScore);
  38. }
  39. if(!tagpro.renderer.layers.ui)
  40. {
  41. var lay = tagpro.renderer.createLayers;
  42. tagpro.renderer.createLayers = function() {
  43. lay();
  44. outlineScore();
  45. }
  46. }
  47. else
  48. {
  49. outlineScore();
  50. }
  51. tagpro.socket.on('end',function() {
  52. end = (new Date).getTime();
  53. })
  54. tagpro.ui.timer = function(e, t, n, r) { //replace r with custom time
  55. var i = tagpro.ui.sprites.timer;
  56. if(!i)
  57. {
  58. i = tagpro.ui.sprites.timer = new PIXI.Text("", {
  59. fill: "#FFFFFF",
  60. strokeThickness: 4,
  61. stroke: "#000000",
  62. font: "bold 30pt Arial"
  63. }), i.alpha = .5, i.anchor.x = .5, e.addChild(tagpro.ui.sprites.timer);
  64. }
  65.  
  66. var time = tagpro.gameEndsAt - (end || (new Date).getTime()), //use current time or whenever game ended
  67. hour = time/6e4 > 60 ? Math.floor(time / 6e4 / 60) + ":" : "", //if more than 60 min, add hour
  68. min = "0" + Math.floor((time / 6e4) % 60),
  69. sec = "0" + Math.floor(time % 6e4 / 1e3); //needs to be Math.ceil on newcompte's server for pre-game (tagpro.state===3), idk why
  70. if(min < 0) min = "00"; if(sec < 0) sec = "00";
  71.  
  72. var clock = hour + min.substr(-2) + ":" + sec.substr(-2); //should match r argument except if >60 min
  73. if(time/1000<startTime) //not <= incase set to 0
  74. {
  75. sec = "0" + Math.floor(time % 6e4 / 1e2)/10 + ".0"; //add .0 in case it's whole number;
  76. clock = hour + min.substr(-2) + ":" + sec.substr(Math.ceil((sec.length-7)/2)*-2-6,4); //quick formula to handle either (0X.0 || 0XX.0) or (0X.X.0 || 0XX.X.0)
  77. if(time<=0)
  78. clock = '00:00.0'; //because the clock keeps running sometimes
  79. }
  80. if (i.text != clock)
  81. i.setText(clock);
  82. }
  83. });
Advertisement
Add Comment
Please, Sign In to add comment