improved behavior and fixed bugs
This commit is contained in:
parent
18052d3d89
commit
ba4d78c3d2
5
click.py
5
click.py
@ -2,7 +2,8 @@ import sys
|
||||
import pyautogui
|
||||
|
||||
|
||||
x = sys.argv[1]
|
||||
y = sys.argv[2]
|
||||
x = int(sys.argv[1])
|
||||
y = int(sys.argv[2])
|
||||
|
||||
print("\n" + str(x) + str(y) + "\n")
|
||||
pyautogui.click(x,y)
|
12
config.jsonc
12
config.jsonc
@ -1,10 +1,10 @@
|
||||
{
|
||||
"photoInterval": 5, //interval in seconds to snap a photo and eat drywall
|
||||
"targetColor": { //target color to click on
|
||||
"r": 0,
|
||||
"g": 0,
|
||||
"b": 0,
|
||||
"photoInterval": 2,
|
||||
"targetColor": {
|
||||
"r": 194,
|
||||
"g": 176,
|
||||
"b": 122,
|
||||
"a": 255
|
||||
},
|
||||
"tolerance": 20 //color tolerance (basic taxicab direction currently)
|
||||
"tolerance": 3
|
||||
}
|
33
main.js
33
main.js
@ -14,6 +14,21 @@ const tolerance = config.tolerance;
|
||||
|
||||
setInterval(eatDrywall, photoInterval * 1000);
|
||||
|
||||
|
||||
|
||||
var readline = require('readline');
|
||||
|
||||
readline.emitKeypressEvents(process.stdin);
|
||||
|
||||
if (process.stdin.isTTY)
|
||||
process.stdin.setRawMode(true);
|
||||
|
||||
process.stdin.on('keypress', (chunk, key) => {
|
||||
if (key && key.name == 'q')
|
||||
process.exit();
|
||||
});
|
||||
|
||||
|
||||
async function eatDrywall() {
|
||||
let monitors = ss.Monitor.all();
|
||||
|
||||
@ -36,13 +51,23 @@ function clickRandomPixelOfColor(width, height, image) {
|
||||
}
|
||||
|
||||
}
|
||||
let click = Math.floor(Math.random() * hits.length); //get index of random viable pixel
|
||||
|
||||
let target = deRasterize(hits[click], width);//get coordinates of random pixel
|
||||
console.log("Clicking: " + target);
|
||||
proc.execSync("python click.py " + target.x + " " + target.y);
|
||||
console.log(hits.length);
|
||||
clickRandomDrywalls(hits,width,1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function clickRandomDrywalls(hits, width, repetitions) {
|
||||
for (let i = 0; i<repetitions; i++) {
|
||||
|
||||
let click = Math.floor(Math.random() * hits.length); //get index of random viable pixel
|
||||
let target = deRasterize(hits[click], width);//get coordinates of random pixel
|
||||
console.log("Clicking: " + JSON.stringify(target));
|
||||
console.log(proc.exec("python click.py " + target.x + " " + target.y).toString());
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
}
|
||||
}
|
||||
function rasterize(x, y, width) { //scale to image
|
||||
return (x + y * width);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user