Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How to use altered variables?



  • Please log in to reply
2 replies to this topic
frankomisko
  • Members
  • 13 posts
  • Last active: Dec 03 2015 11:17 PM
  • Joined: 29 Apr 2013

Ive been trying to make a pixelsearch look in an area defined by another pixelsearch and have been largely unsuccessful~

The main script im working with:

;Kills animals ingame~ finds and clicks to attack, when it dies it dissapears
;so it needs to search around where it was found until its gone, then it finds a new target
,::
loop
{
pixelsearch, houndx, houndy, 805, 483, 1765, 1134, 0xC2706B, 3, fast
if errorlevel
    {
    splashtexton,,, no hound found
    sleep, 500
    splashtextoff
    }
else
    {
    splashtexton,,, hound found
    sleep, 500
    splashtextoff
    mouseclick, left, %houndx%, %houndy%
    sleep, 500
livingsearch:
    pixelsearch, checkx, checky, %houndx%-20, %houndy%-20, %houndx%+20, %houndy%+20, 0xC2706B, 3, fast
    if errorlevel
        {
        splashtexton,,, variable search failed
        sleep, 500
        splashtextoff
        }
    else
        {
        splashtexton,,, variable search worked
        sleep,500
        splashtextoff
        sleep, 1000
        goto, livingsearch
;;;^^^spam returns "search worked" even when desired pixel isnt in search area
        }
    }
}
return

x::
exitapp
return


;Attempt to analyze the problem... changing the variables works but only on the first mousemove
.::
pixelsearch, 1x, 1y, 805, 483, 1765, 1134, 0xC2706B, 3, fast
if errorlevel
    {
    splashtexton,,, failed to find 1x
    sleep, 500
    splashtextoff
    }
else
    {
    splashtexton,,, 1x found
    sleep, 500
    splashtextoff
    sleep, 100
mousemove, %1x%-20, %1y%-20
sleep, 500
mousemove, %1x%+20, %1y%+20
;^^^Only triggers mousemove the first time...?
}
return

Im generally confused with the way variables are handled so if anyone has experience with this id appreciate the info



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012
✓  Best Answer

I would be surprised if it made a difference, but perhaps try pixelsearch, checkx, checky, houndx-20, houndy-20, houndx+20, houndy+20, 0xC2706B, 3, fast? Those parameters automatically evaluate a non-integer input as an expression (evaluate variables, perform math operations), so maybe the %'s throw it off. But they shouldn't...

 

One way to diagnose it may be use MouseMove checkx, checky to see where the pixel it's identifying is. Maybe it is actually similar in color to 0xC2706B.

 

(Edit: Guess they should. But I don't recall having problems doing it the way you had it before, so that's curious. I'll have to experiment harder to see if I can reproduce it.)

 

(Edit 2: Can't reproduce the error. Using the %variable%-20 did not break my code... So maybe it was a problem with not reloading the script after saving it? Spoiler below shows my tested code.)

 

Spoiler


frankomisko
  • Members
  • 13 posts
  • Last active: Dec 03 2015 11:17 PM
  • Joined: 29 Apr 2013

lol looks like that worked~ such a simple fix, thanks