daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // Get current coordinates or jump to new
  3. //
  4. // g()
  5. // g(234,-456)
  6.  
  7. var coords = function() {
  8.     if (!arguments.length) {
  9.         return 'Current coordinates: (' + u.x.toFixed(0) + ', ' + u.y.toFixed(0) +')';
  10.     }
  11.     u.x = arguments[0];
  12.     u.y = u.x;
  13.     if (arguments[1] != undefined) u.y = arguments[1];
  14.     u.y = arguments[1];
  15. };
  16.  
  17. g = coords;
  18.  
  19.  
  20.  
  21. // Get permanent ID of user from current name
  22.  
  23. var getTadpoleID = function(name) {
  24.     for (var w in app.model.tadpoles) {
  25.         if (app.model.tadpoles[w].name == name) {
  26.             console.log('Name: ' + name + ', ID: ' + w);
  27.             return w;
  28.         }
  29.     }
  30.     console.log('Tadpole not found: ' + name);
  31.     return false;
  32. };
  33.  
  34.  
  35.  
  36. // Assign a nickname to a user ID
  37.  
  38. var tadpoleNicks = {};
  39. var setTadpoleNick = function(id, nick) {
  40.     tadpoleNicks[nick] = id * 1;
  41.     return true;
  42. }
  43.  
  44.  
  45.  
  46. // Assign a nickname to a user ID by current name
  47. //
  48. // n('username','newnickname')
  49.  
  50. var setTadpoleNickName = function(name, nick) {
  51.     id = getTadpoleID(name);
  52.     if (!id) return false;
  53.     setTadpoleNick(id, nick);
  54.     console.log("Tadpole '" + name + "' now has the nickname '" + nick + "'");
  55.     return true;
  56. }
  57.  
  58. n = setTadpoleNickName;
  59.  
  60.  
  61.  
  62. // Get tadpole object
  63.  
  64. var getTadpole = function(id) {
  65.     if (app.model.tadpoles[id]) {
  66.         return app.model.tadpoles[id];
  67.     }
  68.     return false;
  69. }
  70.  
  71.  
  72.  
  73. // Get tadpole object by current name
  74.  
  75. var getTadpoleByName = function(name) {
  76.     var id = getTadpoleID(name);
  77.     if (id == false) return false;
  78.     var tad = getTadpole(id);
  79.     return tad;
  80. };
  81.  
  82.  
  83.  
  84. // Get tadpole object by assigned nick
  85.  
  86. var getTadpoleByNick = function(nick) {
  87.     var id = tadpoleNicks[nick];
  88.     if (id == undefined) {
  89.         console.log('Tadpole nick not found: ' + nick);
  90.         return false;
  91.     }
  92.     var tad = getTadpole(id);
  93.     return tad;
  94. };
  95.  
  96.  
  97.  
  98. // Jump next to tadpole's coordinates
  99. // args: <[name]|[nick]|[id]>, [inc]
  100. // inc sets the distance from the target for x and y together
  101. //
  102. // f('username')
  103. // f('nick')
  104. // f(7453)
  105. // f('nick',40)
  106.  
  107. var findTadpole = function() {
  108.     var name = arguments[0];
  109.     var inc = 20;
  110.     if (arguments[1] != undefined) inc = arguments[1];
  111.     var tad = getTadpoleByName(name);
  112.     if (tad == false) {
  113.         tad = getTadpoleByNick(name);
  114.         if (tad == false) {
  115.             tad = getTadpole((name * 1));
  116.             if (tad == false) return false
  117.         }
  118.     }
  119.     u.x = tad.x+inc;
  120.     u.y = tad.y-inc;
  121.     console.log('Warped to: ' + u.x.toFixed(0) + ', ' + u.y.toFixed(0));
  122.     return true;
  123. };
  124.  
  125. f = findTadpole;
  126.  
  127.  
  128.  
  129. // return all tadpoles that have names
  130. //
  131. // gng()
  132.  
  133. var getNonGuests = function() {
  134.     var nonGuests = {};
  135.     for (var w in app.model.tadpoles) {
  136.         var name = app.model.tadpoles[w].name;
  137.         if (name.indexOf('Guest ') != 0) {
  138.            
  139.             nonGuests[w + ' :: ' + name] = app.model.tadpoles[w];
  140.         }
  141.     }
  142.     return nonGuests;
  143. }
  144.  
  145. var gng = getNonGuests;
  146.  
  147.  
  148.  
  149. // userlist!
  150.  
  151. function sidelist(){
  152.     userlist = gng();
  153.     $('#instructions').html('');
  154.         $('#instructions').css({
  155.         'overflow' : 'scroll',
  156.         'height' : '80%'
  157.     });
  158.  
  159.     jQuery.each(userlist, function(i, val) {   
  160.         var arr = i.split(' :: ');   
  161.         arr[1] = arr[1].replace('<','');   
  162.         $('#instructions').append('<p><a href="#" onclick="f('+arr[0]+');">'+arr[1]+'</a></p>');   
  163.     });
  164. //      $('#instructions').append('<p>-----</p><p><a href="#" onclick="g(25000,25000);">[Go to 25k]</a> &nbsp; <a href="#" onclick="sidelist();">[Refresh]</a></p>');
  165.     setTimeout(sidelist,1000);
  166. }
  167.  
  168. sidelist();
  169.  
  170. // Get tadpole that has travelled the farthest from 0,0
  171.  
  172. var getMostDistantTadpole = function() {
  173.     if (arguments[0]) {
  174.         var dir = arguments[0];
  175.     }
  176.     else {
  177.         var dir = false;
  178.     }
  179.     var most = 0;
  180.     var mostID = 0;
  181.     for (var w in app.model.tadpoles) {
  182.         tad = app.model.tadpoles[w];
  183.         if (dir == 'x') {
  184.             curr = tad.x.toFixed(0);
  185.         }
  186.         if (dir == 'y') {
  187.             curr = tad.y.toFixed(0);
  188.         }
  189.         if (dir == false) {
  190.             cx = (tad.x > 0 ? tad.x : tad.x * -1);
  191.             cy = (tad.y > 0 ? tad.y : tad.y * -1);
  192.             curr = cx.toFixed(0)^2 + cy.toFixed(0)^2;
  193.         }
  194.         if (curr > most) {
  195.             console.log(curr + ' :: ' + w);
  196.             most = curr;
  197.             mostID = w;
  198.         }
  199.     }
  200.     return { id: mostID, tad: getTadpole(mostID) };
  201. }
  202.  
  203.  
  204.  
  205. // Get name of most far flung tadpole
  206. //
  207. // md()
  208.  
  209. var showMostDistantTadpole = function() {
  210.     tad = getMostDistantTadpole().tad;
  211.     return mostID + ' :: ' + tad.name + ' :: (' + tad.x.toFixed(0) + ', ' + tad.y.toFixed(0) + ')';
  212. };
  213.  
  214. md = showMostDistantTadpole;
  215.  
  216.  
  217. function bottomlist(){
  218.  
  219.  
  220.  
  221.     $('#wtf').css('display','none');
  222.  
  223.     $('#curspeedli').css('color','white !important');
  224.  
  225.     $('#curspeedli').css('font-size','14px !important');
  226.    
  227.     $('#concept h2').css('display','none');
  228.    
  229.     $('#concept ul').html('<li><a href="#" onclick="app.sendMessage(\'name:\'+prompt());">[Set Name]</a>');
  230.    
  231.     $('#concept ul').append('<li><a href="#" onclick="g(25000,25000);">[Go 25k]</a>');
  232.  
  233.   $('#concept ul').append('<li><a href="#" onclick="u.maxMomentum=u.maxMomentum-5;$(\'#curspeed\').html(Math.round(u.maxMomentum));">[Speed -]</a></li>');
  234.  
  235.   $('#concept ul').append('<li><a href="#" onclick="u.maxMomentum=3;$(\'#curspeed\').html(Math.round(u.maxMomentum));">[Normal]</a></li> ');
  236.  
  237.   $('#concept ul').append('<li><a href="#" onclick="u.maxMomentum=u.maxMomentum+5;$(\'#curspeed\').html(Math.round(u.maxMomentum));">[Speed +]</a></li>');
  238.  
  239.   $('#concept ul').append('<li id="curspeedli"><b>Current Speed: </b><span id="curspeed">3</span></li>');
  240.    
  241.    
  242.  
  243. }
  244. bottomlist();
  245.  
  246.  
  247. // Pay a visit to most far flung tadpole
  248. //
  249. // gmd()
  250.  
  251. var goMostDistantTadpole = function() {
  252.     tad = getMostDistantTadpole().tad;
  253.     u.x = tad.x+20;
  254.     u.y = tad.y-20;
  255.     console.log('Warped to: ' + u.x.toFixed(0) + ', ' + u.y.toFixed(0));
  256.     return true;
  257. };
  258. var gmd = goMostDistantTadpole;
RAW Paste Data
Top