Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

239
Visualizações
Execution of the code is not top to bottom

The execution order does not seem to be correct or I'm missing something.

This is the code:

function main() {
    helper.openRS()
    console.log("START")
    let hexColorsArray = helper.readColorData()
    let startX = 0
    let startY = 627
    let areaX, areaY = 100
    let found = false

    console.log(itemData.grotworm.colors)

    while(!found) {
        colorFound = helper.findColor(startX,startY,areaX,areaY, hexColorsArray)

        console.log("StartX: " + startX + ", StartY: " + startY)
        if(colorFound.state) {
            found = true
            console.log("Color Found?: " + colorFound.state)
            robot.moveMouse(colorFound.random_x, colorFound.random_y)
            robot.mouseClick()
        } else {
            if (startX + 100 >= 1920) {
                startX = 263
                startY -= 100
            } else if (startY < 5) {
                found = true
            } else {
                startX += 100
            }
        }
    }
}

findColor

function findColor(x,y,width,height, colors) {
    let img = robot.screen.capture(x, y, width, height);
    let test = width * height
    let random_x = 0
    let random_y = 0
    let color = []

    for (let i = 0; i < test; i++) {
        random_x = getRandomInt(0, width-1);
        random_y = getRandomInt(0, height-1);
        color = img.colorAt(random_x, random_y)
        console.log("COLOR: " + color)
        if (colors.includes(color)) {
            return {"random_x": random_x + x,"random_y": random_y + y,"state": true};
        }
    }
    
    return {"random_x": 0, "random_y": 0,"state": false}
}

The intention of this code is to read json file of colors in hex and assign it to hexColorsArray, iterate through 100x100 images on the screen and trying to find the correct pixel color in that image, if the color is found the image exits. However the issue I'm having is that the console.log("COLOR: " + color) in the function findColor() prints before anything else.

Head of the output:

$ npm start

> test@1.0.0 start
> node main.js

COLOR: 202020
COLOR: d8eafa
COLOR: 202020
COLOR: 202020
COLOR: 202020
COLOR: 202020
COLOR: ffd253
COLOR: 202020
COLOR: 202020
COLOR: 202020
COLOR: 202020
COLOR: 202020
COLOR: 202020
COLOR: 202020
COLOR: 202020
COLOR: 202020
COLOR: e9e9e9
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda