-
-
Save mably/e28569de3a48c2dddf7735748060edf8 to your computer and use it in GitHub Desktop.
placepaintbot4.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name PlacePaintBot | |
// @namespace http://tampermonkey.net/ | |
// @version 0.4 | |
// @description Domination of Place! | |
// @author mbarkhau | |
// @match https://www.reddit.com/place?webview=true | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var images = [ | |
// ordered by priority | |
// use the debug flag to test your images! | |
{ | |
offsetX: 366, | |
offsetY: 898, | |
text: [ | |
// stop the BUTCOIN and BITCHIN and france! | |
"###.###.##", | |
".#...#..# ", | |
"###..#..##", | |
], | |
}, | |
{ | |
offsetX: 366, | |
offsetY: 898, | |
text: [ | |
// stop the BUTCOIN and BITCHIN and france! | |
"###.###.##.###.###.###", | |
".#...#..# .# #. # .# #", | |
"###..#..##.###.###.# #", | |
], | |
}, | |
{ | |
offsetX: 358, | |
offsetY: 893, | |
text: [ | |
" #####", | |
"##.#.#", | |
"#....#", | |
"#.##.##", | |
"#.....#..... ", | |
"#.###.# ### ### ## ### ### ### ", | |
"#.....# # # # # # # # # ", | |
"##.#.## ### # ## ### ### # # ", | |
".#####.... ", | |
], | |
}, | |
{ | |
offsetX: 357, | |
offsetY: 892, | |
text: [ | |
".", | |
" #####", | |
".##.#.#", | |
".#....#", | |
".#.##.##", | |
".#.....#..... ", | |
".#.###.#.### ### ## ### ### ### ", | |
".#.....# # # # # # # # # ", | |
".##.#.## ### # ## ### ### # # ", | |
"..#####.... ", | |
"........", | |
], | |
}, | |
{ | |
offsetX: 357, | |
offsetY: 892, | |
text: [ | |
".", | |
" #####", | |
".##.#.#", | |
".#....#", | |
".#.##.##..... ###############", | |
".#.....#..... #", | |
".#.###.#.### ### ## ### ### ### #", | |
".#.....#..# # # # # # # # #", | |
".##.#.##.### # ## ### ### # # #", | |
"..#####.... #", | |
"........ ###############", | |
], | |
}, | |
]; | |
var colors = { | |
"o": 0, // white | |
"#": 3, // black | |
" ": 6, // gold | |
".": -1, // ignore | |
}; | |
for (var img_idx = 0; img_idx < images.length; img_idx++) { | |
var image = images[img_idx]; | |
image.image_data = []; | |
for (var relY = 0; relY < image.text.length; relY++) { | |
var row = image.text[relY]; | |
for (var relX = 0; relX < row.length; relX++) { | |
var color = colors[row[relX]] || -1; | |
if (color < 0) { | |
continue; | |
} | |
var absX = image.offsetX + relX; | |
var absY = image.offsetY + relY; | |
image.image_data.push(absX); | |
image.image_data.push(absY); | |
image.image_data.push(color); | |
} | |
} | |
} | |
var default_panX = 120; | |
var default_panY = -380; | |
var p = r.place; | |
p.panX = default_panX; | |
p.panY = default_panY; | |
r.placeModule("placePaintBot", function(loader) { | |
var c = loader("canvasse"); | |
var r = loader("client"); | |
setInterval(function() { | |
var tl = p.getCooldownTimeRemaining(); | |
if (2000 < tl && tl < 3000) {location.reload();} | |
var debug = tl > 3000; | |
if (!debug && tl > 200) {return;} | |
for (var img_idx = 0; img_idx < images.length; img_idx++) { | |
var image = images[img_idx]; | |
for (var i = 0; i < image.image_data.length; i += 3) { | |
var j = Math.floor((Math.random() * image.image_data.length) / 3) * 3; | |
var x = image.image_data[j + 0]; | |
var y = image.image_data[j + 1]; | |
var color = image.image_data[j + 2]; | |
var currentColor = p.state[c.getIndexFromCoords(x, y)]; | |
if (currentColor != color) { | |
if (debug) { | |
p.state[c.getIndexFromCoords(x, y)] = color; | |
c.setBufferState(c.getIndexFromCoords(x, y), r.getPaletteColorABGR(color)); | |
} else { | |
console.log("set color for", x, y, "old", currentColor, "new", color); | |
p.setColor(color); | |
p.drawTile(x, y); | |
} | |
return; | |
} | |
} | |
console.log("noop"); | |
} | |
}, 200); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment