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0,0,0,0,0,0,3,3,3
,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,3,3
,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,0,0,0,0,3
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,0,0,0,0,0,0,3,0,0,3
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,3,0,0,0,0,3,3
,0,0,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,3,0,0,3,3,3
,0,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,0,0,3,3,3,3,3,3
,0,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3,3,3,3,3,0
,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3,3,3,3,0
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3,3,0,0
,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3,3,0,0
,0,0,0,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0
,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0
,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0
];
var colorsABGR = [];
var babaevski = {
x: 969,
y: 523,
width: 30,
height: 30
};
var perfect_timeout = 60;
// hooks
var client;
var canvasse;
var jQuery;
var currentDrawPosition = babaevski.width*babaevski.height / 2;
var currentLoop = 0;
r.placeModule("babaevski", 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 < babaevski.width*babaevski.height)
{
currentLoop++;
console.log("checking pixel " + currentDrawPosition);
var targetPoint = getPoint(currentDrawPosition);
$.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 >= babaevski.width*babaevski.height)
currentDrawPosition = 0;
tryDrawPixel(currentDrawPosition);
}
}, 300);
});
}
else
{
var added_timeout = 0;
if (currentLoop == babaevski.width*babaevski.height)
added_timeout = perfect_timeout*1000;
setTimeout(attempt, toWait + Math.round(Math.random() * 1500) + added_timeout);
currentLoop = 0;
console.log("set a timeout");
}
}
function drawTestRTC(){
for(var i=0; i < babaevski.width*babaevski.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 % babaevski.width;
return {
x: babaevski.x + x,
y: babaevski.y + (i - x) / babaevski.width - babaevski.height
};
}
function getPixel(x, y){
return canvasse.writeBuffer[canvasse.getIndexFromCoords(x, y)];
}
We kludged together a script you can run in developer console if you have an account that's just idling!
Will put the logo here when it is finished (bottom right of the general map)