Advertisement
Guest User

r/foxes v1.1

a guest
Apr 3rd, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * -1 = pass
  3.  * 0  = white
  4.  * 1  = lgray
  5.  * 2  = dgray
  6.  * 3  = black
  7.  * 4  = lpink
  8.  * 5  = red
  9.  * 6  = orange
  10.  * 7  = brown
  11.  * 8  = yellow
  12.  * 9  = lgreen
  13.  * 10 = green
  14.  * 11 = cyan
  15.  * 12 = blue
  16.  * 13 = hard blue
  17.  * 14 = light purple/pink
  18.  * 15 = purple
  19.  */
  20.  
  21. var colors = [
  22. /*
  23. 0  1  2  3   4  5  6  7   8  9  10 11  12 13 14 15  16 17 18 19  20 21 22 23  24 25 26 27  28 29 30 31 */
  24.  9, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,
  25.  9, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,  9, 3, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,
  26. 10, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 3,  3, 3, 9,10, 10,10, 9, 9, 10, 9, 9,10,  9,10, 9, 9,
  27.  9, 9, 9, 3,  9, 9, 9, 9,  9, 9,10, 9,  9, 9, 3, 3,  9, 3, 9,10,  9, 9, 9,10,  9,10, 9,10,  9,10, 9, 9,
  28.  
  29.  9, 9, 9, 3,  3, 3, 9, 9,  9, 9, 9, 9,  9, 3, 3, 6,  6, 3, 9,10, 10,10, 9,10,  9,10, 9, 9, 10, 9, 9, 9,
  30.  9, 9, 9, 3,  3, 3, 3, 3,  9, 9, 9, 9,  3, 3, 6, 6,  0, 3, 9,10,  9, 9, 9,10,  9,10, 9,10,  9,10, 9, 9,
  31.  9,10, 9, 3,  6, 6, 3, 3,  3, 3, 3, 3,  3, 6, 6, 0,  0, 3, 9,10,  9, 9, 9, 9, 10, 9, 9,10,  9,10, 9, 9,
  32.  9, 9, 9, 3,  6, 0, 6, 6,  3, 6, 6, 6,  6, 6, 6, 0,  0, 3, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,
  33.  
  34.  9, 9, 9, 3,  6, 0, 0, 6,  6, 6, 6, 6,  6, 6, 6, 6,  6, 3, 3, 9,  9, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,
  35.  9, 9, 9, 3,  6, 0, 0, 6,  6, 6, 6, 6,  6, 6, 6, 6,  6, 7, 3, 3,  9, 9, 9, 9,  9, 9,10, 9,  9, 9, 9, 9,
  36.  9, 9, 9, 9,  3, 0, 6, 6,  6, 6, 6, 6,  6, 6, 6, 6,  6, 6, 7, 3,  3, 9,10, 9,  9, 9, 9, 9,  9, 9, 9, 9,
  37.  9, 9, 9, 9,  3, 6, 6, 6,  6, 6, 6, 6,  6, 6, 6, 6,  6, 6, 6, 7,  3, 9, 9, 9,  9, 9, 9, 9,  9, 9, 9, 9,
  38.  
  39.  9, 9, 9, 9,  3, 6, 6, 6,  6, 6, 6, 6,  6, 6, 6, 0,  3, 3, 6, 6,  3, 3, 3, 3,  3, 3, 9, 9,  9, 9,10, 9,
  40.  9, 9, 9, 3,  6, 6, 6, 0,  3, 3, 6, 6,  6, 6, 6, 3,  3, 3, 3, 6,  3, 6, 6, 7,  7, 7, 3, 9,  9, 9, 9, 9,
  41.  9, 9, 9, 3,  6, 6, 6, 3,  3, 3, 3, 6,  6, 6, 6, 3,  3, 0, 3, 6,  3, 6, 6, 6,  6, 7, 7, 3,  9, 9, 9, 9,
  42.  9, 9, 9, 3,  6, 6, 6, 3,  3, 0, 3, 6,  6, 6, 6, 6,  3, 3, 6, 3,  6, 6, 6, 6,  6, 6, 7, 7,  3, 9, 9, 9,
  43.  
  44.  9, 9, 9, 3,  3, 0, 6, 6,  3, 3, 6, 6,  6, 6, 6, 6,  6, 6, 0, 3,  6, 3, 3, 3,  3, 3, 7, 7,  3, 9, 9, 9,
  45.  9, 9, 9, 3,  3, 3, 0, 0,  0, 0, 6, 6,  6, 6, 6, 6,  6, 0, 3, 7,  3, 3, 7, 6,  6, 6, 3, 3,  3, 3, 9, 9,
  46.  9, 9, 3, 0,  0, 0, 3, 3,  0, 0, 0, 0,  6, 6, 6, 6,  0, 3, 3, 3,  3, 7, 6, 6,  6, 6, 6, 6,  3, 3, 9, 9,
  47.  9, 9, 3, 0,  0, 0, 0, 0,  3, 3, 3, 0,  0, 3, 3, 3,  3, 3, 7, 7,  7, 6, 6, 6,  6, 6, 6, 6,  7, 3, 9, 9,
  48.  
  49.  9,10, 3, 0,  0, 0, 0, 0,  1, 1, 1, 3,  3, 3, 3, 3,  7, 7, 7, 6,  6, 6, 6, 6,  6, 6, 6, 6,  7, 3, 9, 9,
  50.  9,10, 3, 0,  0, 0, 0, 0,  1, 1, 7, 7,  7, 7, 7, 7,  7, 7, 6, 6,  6, 6, 6, 6,  6, 6, 6, 6,  7, 3, 9, 9,
  51.  9,10, 3, 1,  0, 0, 0, 1,  1, 6, 6, 6,  7, 7, 7, 7,  7, 6, 6, 6,  6, 6, 6, 6,  6, 6, 6, 7,  7, 3, 9, 9,
  52.  9,10, 3, 1,  1, 1, 0, 0,  1, 1, 6, 6,  6, 6, 7, 7,  6, 6, 6, 6,  6, 6, 6, 6,  6, 6, 6, 7,  3,10, 9, 9,
  53.  
  54.  9,10,10, 3,  1, 1, 6, 6,  6, 0, 6, 6,  6, 6, 6, 6,  6, 6, 6, 6,  6, 6, 6, 6,  6, 6, 7, 7,  3, 9, 9,-1,
  55.  9, 9,10, 3,  1, 1, 1, 6,  6, 6, 6, 6,  6, 6, 6, 6,  6, 6, 6, 6,  6, 6, 6, 6,  6, 7, 7, 3, 10, 9,-1,-1,
  56.  9, 9,10,10,  3, 6, 6, 6,  6, 6, 6, 6,  6, 6, 6, 6,  6, 6, 6, 6,  6, 6, 6, 7,  7, 7, 3,10,  9,-1,-1,-1,
  57.  9, 9, 9,10, 10, 3, 3, 6,  6, 6, 6, 6,  6, 6, 6, 6,  6, 6, 6, 6,  6, 7, 7, 7,  3, 3,10, 9, -1,-1,-1,-1,
  58.  
  59.  9, 9, 9, 9, 10,10,10, 3,  3, 3, 3, 3,  3, 3, 3, 3,  3, 3, 3, 3,  3, 3, 3, 3, 10,10, 9,-1, -1,-1,-1,-1,
  60.  9, 9, 9, 9,  9, 9,10,10, 10,10,10,10, 10,10,10,10, 10,10,10,10, 10,10,10,10,  9, 9,-1,-1, -1,-1,-1,-1,
  61.  9, 9, 9, 9,  9, 9, 9, 9, 10,10,10,10, 10,10,10,10, 10,10,10,10, 10,10, 9, 9,  9,-1,-1,-1, -1,-1,-1,-1,
  62. ];
  63.  
  64. var colorsABGR = [];
  65.  
  66. var fox = {
  67.   x: 31,
  68.   y: 68,
  69.   width: 32,
  70.   height: 31
  71. };
  72.  
  73. var placed = 0;
  74.  
  75. // hooks
  76. var client;
  77. var canvasse;
  78. var jQuery;
  79.  
  80. var test = 0;
  81.  
  82. r.placeModule("fox", function(e){
  83.   client = e("client");
  84.   canvasse = e("canvasse");
  85.   jQuery = e("jQuery");
  86.  
  87.   for(var i=0; i<client.palette.length; i++){
  88.     colorsABGR[i] = client.getPaletteColorABGR(i);
  89.   }
  90.  
  91.   // Start
  92.   if(!test){
  93.     attempt();
  94.   } else {
  95.     drawTestFox();
  96.   }
  97. });
  98.  
  99. function attempt(){
  100.   var toWait = client.getCooldownTimeRemaining();
  101.   if(toWait === 0){
  102.      for(var i=0; i<colors.length; i++){
  103.         if(colors[i] === -1){
  104.           continue;
  105.         }
  106.         var targetPoint = getPoint(i);
  107.         var pixelColor = getPixel(targetPoint.x, targetPoint.y);
  108.         if(pixelColor !== colorsABGR[colors[i]]){
  109.             client.setColor(colors[i]);
  110.             client.drawTile(targetPoint.x, targetPoint.y);
  111.             console.log('Pixel Placed at: (' + targetPoint.x + ',' + targetPoint.y + ')');
  112.             break;
  113.         }
  114.      }
  115.   }
  116.   setTimeout(attempt, toWait + Math.round(Math.random() * 1500));
  117. }
  118.  
  119. function drawTestFox(){
  120.   for(var i=0; i<colors.length; i++){
  121.     if(colors[i] === -1){
  122.       continue;
  123.     }
  124.     var targetPoint = getPoint(i);
  125.     canvasse.drawTileAt(targetPoint.x, targetPoint.y, colorsABGR[colors[i]]);
  126.   }
  127. }
  128.  
  129. function getPoint(i){
  130.   var x = i % fox.width;
  131.   return {
  132.     x: fox.x + x,
  133.     y: fox.y + (i - x) / fox.width - fox.height
  134.   };
  135. }
  136.  
  137. function getPixel(x, y){
  138.   return canvasse.writeBuffer[canvasse.getIndexFromCoords(x, y)];
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement