chrahunt

texture pack loader

Feb 28th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name          My Texture Pack Loader
  3. // @namespace     http://www.reddit.com/u/snaps_/
  4. // @description   Used for texture pack loading.
  5. // @include       http://tagpro-*.koalabeast.com:*
  6. // @include       http://tangent.jukejuice.com:*
  7. // @include       http://*.newcompte.fr:*
  8. // @license       GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
  9. // @author        snaps
  10. // @version       0.1.0
  11. // @resource  tiles  http://i.imgur.com/YnJ9THs.png
  12. // @resource  speedpad  http://i.imgur.com/Lgiwb5Q.png
  13. // @resource  speedpadRed  http://i.imgur.com/XuN3NbB.png
  14. // @resource  speedpadBlue  http://i.imgur.com/5JKeYSQ.png
  15. // @resource  portal  http://i.imgur.com/xJe0hBy.png?1
  16. // @resource  splats  http://i.imgur.com/RZYNTYs.png
  17. // ==/UserScript==
  18.  
  19. // Wait until the tagpro object exists, and add the function to tagpro.ready
  20. function waitForTagpro(fn) {
  21.     // Make sure the tagpro object exists.
  22.     if (typeof tagpro !== "undefined") {
  23.         fn();
  24.     } else {
  25.         // If not ready, try again after a short delay.
  26.         setTimeout(function() {
  27.             waitForTagpro(fn);
  28.         }, 0);
  29.     }
  30. }
  31.  
  32. var loadTexture = function() {
  33.     var assetTypes = ["tiles", "speedpad", "speedpadRed", "speedpadBlue", "portal", "splats"];
  34.     var assets = {};
  35.     assetTypes.forEach(function(assetType) {
  36.         assets[assetType] = GM_getResourceURL(assetType);
  37.     });
  38.     tagpro.loadAssets(assets);
  39. };
  40. waitForTagpro(loadTexture);
Add Comment
Please, Sign In to add comment