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3,3,5,5,5,5,5,5,3,8,8,8,3,8,8,8,8,8,3,//430
- 5,5,5,5,3,3,8,8,8,3,3,5,5,5,5,5,3,8,8,8,8,8,8,8,3,5,//431
- 5,5,5,3,8,8,8,8,8,8,8,3,3,3,3,3,3,3,8,8,8,8,8,8,3,5,//432
- 5,5,5,3,8,8,8,3,3,8,8,8,8,8,8,8,8,8,8,8,8,8,8,3,5,5,//433
- 5,5,3,8,8,8,8,3,5,3,8,8,8,8,8,8,8,8,8,8,8,8,8,8,3,5,//434
- 5,3,8,8,8,3,3,5,5,5,3,3,8,8,8,8,8,8,8,8,8,8,8,8,8,3,//435
- 3,8,8,8,3,5,5,5,5,5,5,5,3,3,3,3,3,3,3,3,3,8,8,8,8,3,//436
- 3,8,8,3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3,8,8,8,3,//437
- 5,3,3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3,3,3,5,//438
- ];
- var colorsABGR = [];
- var FULLY = {
- x: 3,
- y: 438,
- width: 26,
- height: 26
- };
- var perfect_timeout = 60;
- // hooks
- var client;
- var canvasse;
- var jQuery;
- var currentDrawPosition = Math.floor(Math.random() * FULLY.width*FULLY.height);
- var currentLoop = 0;
- r.placeModule("FULLY", function(e){
- client = e("client");
- canvasse = e("canvasse");
- jQuery = e("jQuery");
- for(var i=0; i<client.palette.length; i++){
- colorsABGR[i] = client.getPaletteColorABGR(i);
- }
- attempt();
- });
- function attempt(){
- console.log("tried to draw");
- var toWait = client.getCooldownTimeRemaining();
- if(toWait === 0)
- {
- tryDrawPixel();
- }
- else
- {
- setTimeout(attempt, toWait + Math.round(Math.random() * 1500));
- console.log("set a timeout");
- }
- }
- function tryDrawPixel()
- {
- var toWait = client.getCooldownTimeRemaining();
- if(toWait === 0 && currentLoop < FULLY.width*FULLY.height)
- {
- currentLoop++;
- console.log("checking pixel " + currentDrawPosition);
- var targetPoint = getPoint(currentDrawPosition);
- try{
- $.get( "/api/place/pixel.json", { x:targetPoint.x, y:targetPoint.y }, function( data )
- {
- setTimeout(function() {
- //wait an extra half second for reddits servers
- console.log("x" + targetPoint.x + " y"+ targetPoint.y);
- if (data.color == undefined)
- data.color = 0;
- canvasse.drawTileAt(data.x, data.y, colorsABGR[data.color]);
- if (colors[currentDrawPosition] != data.color && colors[currentDrawPosition] !== -1)
- {
- client.setColor(colors[currentDrawPosition]);
- client.drawTile(targetPoint.x, targetPoint.y);
- console.log("drew pixel at " + targetPoint.x + "/" + targetPoint.y);
- var toWait = client.getCooldownTimeRemaining();
- setTimeout(attempt, toWait + Math.round(Math.random() * 1500));
- currentLoop = 0;
- console.log("set a timeout");
- }
- else
- {
- var positionIncrease = Math.floor(Math.random() * (Math.min(0.2*currentLoop, 40))) + 1;
- currentDrawPosition += positionIncrease;
- //console.log("" + currentLoop + ", " +positionIncrease);
- if (currentDrawPosition >= FULLY.width*FULLY.height)
- currentDrawPosition = Math.floor(Math.random() * FULLY.width*FULLY.height);
- tryDrawPixel(currentDrawPosition);
- }
- }, 300);
- });
- }
- catch(e){
- alert("test");
- }
- }
- else
- {
- var added_timeout = 0;
- if (currentLoop == FULLY.width*FULLY.height)
- added_timeout = perfect_timeout*1000;
- setTimeout(attempt, toWait + Math.round(Math.random() * 1500) + added_timeout);
- currentLoop = 0;
- console.log("set a timeout");
- }
- }
- function drawTest(){
- for(var i=0; i < FULLY.width*FULLY.height; i++){
- if(colors[i] === -1){
- continue;
- }
- var targetPoint = getPoint(i);
- canvasse.drawTileAt(targetPoint.x, targetPoint.y, colorsABGR[colors[i]]);
- }
- }
- function getPoint(i){
- var x = i % FULLY.width;
- return {
- x: FULLY.x + x,
- y: FULLY.y + (i - x) / FULLY.width - FULLY.height
- };
- }
- function getPixel(x, y){
- return canvasse.writeBuffer[canvasse.getIndexFromCoords(x, y)];
- }
Add Comment
Please, Sign In to add comment