From ba4d78c3d2da5f01a5658b10e4c33c5e9b8bf3be Mon Sep 17 00:00:00 2001 From: APEX FIGHT Date: Tue, 8 Apr 2025 21:03:52 -0400 Subject: [PATCH] improved behavior and fixed bugs --- click.py | 5 +++-- config.jsonc | 12 ++++++------ main.js | 33 +++++++++++++++++++++++++++++---- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/click.py b/click.py index c298fa7..e3dbda4 100644 --- a/click.py +++ b/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) \ No newline at end of file diff --git a/config.jsonc b/config.jsonc index e484971..e3fd30f 100644 --- a/config.jsonc +++ b/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 } \ No newline at end of file diff --git a/main.js b/main.js index 03bff76..9ec9ada 100644 --- a/main.js +++ b/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 setTimeout(resolve, 300)); + } +} function rasterize(x, y, width) { //scale to image return (x + y * width); }