Jump to content

Need help with finding the bitmap(MacBook)! (sorry if this is the wrong place to post)


lukas123123

Recommended Posts

This is my script trying to steal from a "Stall" , the program can't seem to find the "stall" and i don't know why. Ive got the colors right and it should find it within my BITMAP my it wont.
 
function findStall() {
var x = 200, y = 170, width = 700, height = 500;
var img = robot.screen.capture(x, y, width, height);
 
var size = (700, 500);
var img = robot.screen.capture(0, 0, size, size);
var multi = img.width / size;
;
 
 
var stallColors = ["#8e7493", "#424254", "#51093d", "#393946", "#69094e"];
 
for(var i = 0; i < 1000; i++) {
var randomX = getRandomInt(0, width-1);
var randomY = getRandomInt(0, height-1);
var sampleColor = img.colorAt(200 * multi, 170 * multi);
 
if(stallColors.includes(sampleColor)) {
var screenX = randomX + x;
var screenY = randomY + y;
 
console.log("found stall: " + screenX + "," + screenY + " color " + sampleColor);
return {x: screenX, y: screenY}
}
}
 
// this is the part where im trying to find the stall using colorpixels and bitmap width and lenght.
 
------------------------------------------------------------------------------------------
// this is my whole code.
 
// import the robotjs library
var robot = require('robotjs');

 

// hela functionen av programmet
function main() {
console.log("Starting...");
sleep(4000);

 

var stall = findStall();
if(stall == false) {
//om ingen stall hittar break programet
console.log('could not find stall');
}

 

// tar från stall och droppar
while (true) {
robot.moveMouse(stall.x, stall.y);
robot.mouseClick();
sleep(3000);

 

dropSilk();
break;
}
}

 

//function för att droppa silk

 

function dropSilk() {
var inventoryX = 950;
var inventoryY = 437;
robot.moveMouse(inventoryX, inventoryY);
robot.mouseClick('right');
robot.moveMouse(inventoryX, inventoryY + 50);
robot.mouseClick();
sleep(3000);
}

 

function findStall() {
var x = 200, y = 170, width = 700, height = 500;
var img = robot.screen.capture(x, y, width, height);

 

var size = (700, 500);
var img = robot.screen.capture(0, 0, size, size);
var multi = img.width / size;
;
 

 

var stallColors = ["#8e7493", "#424254", "#51093d", "#393946", "#69094e"];

 

for(var i = 0; i < 1000; i++) {
var randomX = getRandomInt(0, width-1);
var randomY = getRandomInt(0, height-1);
var sampleColor = img.colorAt(200 * multi, 170 * multi);

 

if(stallColors.includes(sampleColor)) {
var screenX = randomX + x;
var screenY = randomY + y;

 

console.log("found stall: " + screenX + "," + screenY + " color " + sampleColor);
return {x: screenX, y: screenY}
}
}

 

// hittade inte Stall
return false;

 

}

 

//sleep funktion används genom att skriva sleep(3000);
function sleep(ms) {
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
}

 

function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}

 

//kör hela programet
main();
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...