Jump to content
Sign in to follow this  
TiD

Script consuming high resources

Recommended Posts

TiD

Sleep(250)
$pixelcolor = 0;
$walk = 2;
Opt("PixelCoordMode", 2)
Opt("ColorMode", 0)

while $walk > 1
    if pixelgetcolor(960,501) = 1638144 then
        sleep(1250)
        Send("{Q down}")
        Sleep(1000)
        Send("{Q up}")
        Sleep(750)
        Send("{A down}")
        Sleep(90)
        Send("{A up}")
        Sleep(550)
        Send("{W down}")
        Sleep(20000)
        Send("{W up}")
        Sleep(550)
        Send("{E down}")
        Sleep(1000)
        Send("{E up}")
        Sleep(550)
        Send("{W down}")
        Sleep(7000)
        Send("{W up}")
        Sleep(550)
        Send("{E down}")
        Sleep(1000)
        Send("{E up}")
        Sleep(550)
        Send("{W down}")
        Sleep(7000)
        Send("{W up}")
        Sleep(550)
        Send("{E down}")
        Sleep(1000)
        Send("{E up}")
        Sleep(550)
        Send("{W down}")
        Sleep(7000)
        Send("{W up}")
        Sleep(550)
        Send("{0}")
        Sleep(20000)
        Send("{Q down}")
        Sleep(1200)
        Send("{Q up}")
        Sleep(550)
        Send("{W down}")
        Sleep(10000)
        Send("{W up}")
        Sleep(550)
        Send("{E down}")
        Sleep(2000)
        Send("{E up}")
        Sleep(550)
        Send("{W down}")
        Sleep(2000)
        Send("{W up}")
        Sleep(550)
        Send("{Q down}")
        Sleep(3000)
        Send("{Q up}")
    EndIf
WEnd

My script has been using up 50% or more of my cpu when I'm running it. I have other scripts that aren't having this problem. I'm pretty sure that the if pixelgetcolor statement is the problem - what am I doing wrong?

Share this post


Link to post
Share on other sites
Helge

Add a tiny Sleep() inside the loop, outside the If-statement.

Share this post


Link to post
Share on other sites
bigassmuffin

And yourright, the pixel search consumes alot of energey

;Sleep(250)
$pixelcolor = 0;
$walk = 2;
Opt("PixelCoordMode", 2)
Opt("ColorMode", 0)

while $walk > 1
    sleep(1500) ;taken fomr inside of loop,m and added 250 from top
    if pixelgetcolor(960,501) = 1638144 then
        ;sleep(1250) i put this outside of if statment so it waits before runnign again
        Send("{Q down}")
        Sleep(1000)
        Send("{Q up}")
        Sleep(750)
        Send("{A down}")
        Sleep(90)
        Send("{A up}")
        Sleep(550)
        Send("{W down}")
        Sleep(20000)
        Send("{W up}")
        Sleep(550)
        Send("{E down}")
        Sleep(1000)
        Send("{E up}")
        Sleep(550)
        Send("{W down}")
        Sleep(7000)
        Send("{W up}")
        Sleep(550)
        Send("{E down}")
        Sleep(1000)
        Send("{E up}")
        Sleep(550)
        Send("{W down}")
        Sleep(7000)
        Send("{W up}")
        Sleep(550)
        Send("{E down}")
        Sleep(1000)
        Send("{E up}")
        Sleep(550)
        Send("{W down}")
        Sleep(7000)
        Send("{W up}")
        Sleep(550)
        Send("{0}")
        Sleep(20000)
        Send("{Q down}")
        Sleep(1200)
        Send("{Q up}")
        Sleep(550)
        Send("{W down}")
        Sleep(10000)
        Send("{W up}")
        Sleep(550)
        Send("{E down}")
        Sleep(2000)
        Send("{E up}")
        Sleep(550)
        Send("{W down}")
        Sleep(2000)
        Send("{W up}")
        Sleep(550)
        Send("{Q down}")
        Sleep(3000)
        Send("{Q up}")
    EndIf
WEnd

This changing of code and numbers will not chancge script, only difference is before it would wait 1.5 seconds FIRST LOOP, then 1.25 seconds every time after that, this one will do 1.5 seconds EVERY time. You cant really speed up a pixelsearch that much thoguh

Edited by bigassmuffin

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.