Sign in to follow this  
Followers 0
Roman9

Quick help please

7 posts in this topic

#1 ·  Posted (edited)

I'm having trouble writting a script that waits 5 seconds then checks for a change in a pixel for 6 seconds, and if there are no changes, exits.

If there is a change in the pixel, then it does something else... Here's what I've got so far... Am I doing this right?

Func Wait()                 
    Sleep(5000)             
    Do PixelGetColor(176, 106) Until    
    PixelGetColor(176, 106) = 0x4A96FF  
    or timer() = 0  
EndFunc

And if that looks fine, how do I make a 6 second countdown timer function?

Edited by Roman9

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Is this what you wanted?

Func Wait()              
    Sleep(5000)
    $TimerInit=TimerInit()
    Do PixelGetColor(176, 106) Until   
    PixelGetColor(176, 106) = 0x4A96FF Or $TimerDiff($TimerInit)>6000
EndFunc

Edit: Wrong click

Edited by Generator

Share this post


Link to post
Share on other sites

Thanks :)

@JdeB, by fire you mean the color? :P

Share this post


Link to post
Share on other sites

Ok guys I've been working on it but it gives me errors when I Tidy it up... I have a feeling I didn't do what I'm trying to do in the smartest manner, please help me out.

Func Wait()
    Sleep(5000)     ;wait 5 seconds
    $Timer = TimerInit()    ;timer starts
    MouseMove(118, 59)  ;Making sure it checks the correct pixel
    Do PixelGetColor(118, 59)   ;Keep on checking the color until it turns blue or
    Until PixelGetColor(118, 59) = 0x4A96FF Or $TimerDiff ($TimerInit) > 7000 ;7 seconds pass, after which we restart the loop
    If PixelGetColor(118, 59) = 0x4A96FF Then ;If it does turn blue, then
        $TimerInit = 0  ;restart the timer
        Do PixelGetColor(117, 74)  ;Keep on getting the color of the new coordinates
        Until $TimerDiff ($TimerInit) > 7000    ;for 7 seconds.
        If PixelGetColor(117, 74) = 0x4A96FF Then Send("{SPACE down}")   ;If the color is blue, hold space }
        If PixelGetColor(117, 74) = 0xFF0808 Then Send("{SPACE up}")    ;if the color is red, let go.      } --Color changes so I need to keep on checking it
    EndIf
;### Tidy Error -> "endif" is closing previous "func"
EndIf
;### Tidy Error: next line creates a negative tablevel.
;### Tidy Error: next line creates a negative tablevel for the line after it.
EndIf
;### Tidy Error: next line creates a negative tablevel.
;### Tidy Error: next line creates a negative tablevel for the line after it.
EndFunc   ;==>Wait

Thank you

Share this post


Link to post
Share on other sites

Here you go

Func Wait()
    Sleep(5000)     ;wait 5 seconds
    $Timer = TimerInit()    ;timer starts
    MouseMove(118, 59)  ;Making sure it checks the correct pixel
    Do
        PixelGetColor(118, 59)   ;Keep on checking the color until it turns blue or
    Until PixelGetColor(118, 59) = 0x4A96FF Or $TimerDiff ($TimerInit) > 7000 ;7 seconds pass, after which we restart the loop
    If PixelGetColor(118, 59) = 0x4A96FF Then ;If it does turn blue, then
        $TimerInit = 0
    EndIf;restart the timer
    Do
        PixelGetColor(117, 74)  ;Keep on getting the color of the new coordinates
    Until $TimerDiff ($TimerInit) > 7000    ;for 7 seconds.
    If PixelGetColor(117, 74) = 0x4A96FF Then Send("{SPACE down}")   ;If the color is blue, hold space }
    If PixelGetColor(117, 74) = 0xFF0808 Then Send("{SPACE up}")    ;if the color is red, let go.     } --Color changes so I need to keep on checking it
EndFunc   ;==>Wait

Share this post


Link to post
Share on other sites

Thanks Generator! :)

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  
Followers 0