Compare commits
2 Commits
8798d7b2a7
...
57f3767d57
Author | SHA1 | Date | |
---|---|---|---|
![]() |
57f3767d57 | ||
![]() |
a2c522fea2 |
@ -3,7 +3,10 @@
|
|||||||
A bot for eat drywall probably idk.
|
A bot for eat drywall probably idk.
|
||||||
|
|
||||||
|
|
||||||
|
Setup with `start setup.bat`.
|
||||||
|
|
||||||
Run with `node main`.
|
Run with `python start.py`.
|
||||||
|
|
||||||
|
Press "q" anywhere to quit.
|
||||||
|
|
||||||
Configure in "config.jsonc".
|
Configure in "config.jsonc".
|
||||||
|
6
click.py
6
click.py
@ -6,6 +6,6 @@ x = int(sys.argv[1])
|
|||||||
y = int(sys.argv[2])
|
y = int(sys.argv[2])
|
||||||
|
|
||||||
print("\n" + str(x) + str(y) + "\n")
|
print("\n" + str(x) + str(y) + "\n")
|
||||||
pyautogui.moveTo(x,y, .3)
|
pyautogui.moveTo(x,y, .1)
|
||||||
pydirectinput.moveTo(x,y, .3)
|
pydirectinput.moveTo(x,y)
|
||||||
pyautogui.click(clicks=2, interval=.35)
|
pyautogui.click(clicks=4, interval=.1)
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"iterationsPerPhoto": 6,
|
||||||
"photoInterval": 2,
|
"photoInterval": 2,
|
||||||
"targetColor": {
|
"targetColor": {
|
||||||
"r": 85,
|
"r": 85,
|
||||||
@ -6,5 +7,5 @@
|
|||||||
"b": 49,
|
"b": 49,
|
||||||
"a": 255
|
"a": 255
|
||||||
},
|
},
|
||||||
"tolerance": 2
|
"tolerance": 20
|
||||||
}
|
}
|
17
main.js
17
main.js
@ -3,6 +3,7 @@ const ss = require("node-screenshots");
|
|||||||
const proc = require("child_process");
|
const proc = require("child_process");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
||||||
|
|
||||||
let config = JSON.parse(fs.readFileSync("./config.jsonc"));
|
let config = JSON.parse(fs.readFileSync("./config.jsonc"));
|
||||||
|
|
||||||
const photoInterval = config.photoInterval;
|
const photoInterval = config.photoInterval;
|
||||||
@ -11,22 +12,13 @@ const targetColor = config.targetColor;
|
|||||||
|
|
||||||
const tolerance = config.tolerance;
|
const tolerance = config.tolerance;
|
||||||
|
|
||||||
|
const iterationsPerPhoto = config.iterationsPerPhoto;
|
||||||
|
|
||||||
setInterval(eatDrywall, photoInterval * 1000);
|
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() {
|
async function eatDrywall() {
|
||||||
@ -53,7 +45,7 @@ function clickRandomPixelOfColor(width, height, image) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log(hits.length);
|
console.log(hits.length);
|
||||||
clickRandomDrywalls(hits,width,1);
|
clickRandomDrywalls(hits, width, iterationsPerPhoto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +57,7 @@ async function clickRandomDrywalls(hits, width, repetitions) {
|
|||||||
let target = deRasterize(hits[click], width);//get coordinates of random pixel
|
let target = deRasterize(hits[click], width);//get coordinates of random pixel
|
||||||
console.log("Clicking: " + JSON.stringify(target));
|
console.log("Clicking: " + JSON.stringify(target));
|
||||||
console.log(proc.exec("python click.py " + target.x + " " + target.y).toString());
|
console.log(proc.exec("python click.py " + target.x + " " + target.y).toString());
|
||||||
await new Promise(resolve => setTimeout(resolve, 300));
|
await new Promise(resolve => setTimeout(resolve, 200));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function rasterize(x, y, width) { //scale to image
|
function rasterize(x, y, width) { //scale to image
|
||||||
@ -84,6 +76,7 @@ function compareColors(c1, c2) { //compare two rgba color structs
|
|||||||
let sum2 = c2.r + c2.g + c2.b + c2.a;
|
let sum2 = c2.r + c2.g + c2.b + c2.a;
|
||||||
|
|
||||||
if (Math.abs(sum1 - sum2) < (tolerance * 4)) {
|
if (Math.abs(sum1 - sum2) < (tolerance * 4)) {
|
||||||
|
//console.log(Math.abs(sum1 - sum2));
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
python -m ensurepip
|
python -m ensurepip
|
||||||
pip install pyautogui
|
pip install pyautogui
|
||||||
pip install PyDirectInput
|
pip install PyDirectInput
|
||||||
|
pip install keyboard
|
||||||
npm i
|
npm i
|
Loading…
x
Reference in New Issue
Block a user