help with colors for a script im trying to make?

Discussion in 'Code Snippets and Tutorials' started by deathcraze, Jan 5, 2008.

  1. deathcraze

    deathcraze Level III

    Joined:
    Mar 3, 2007
    Messages:
    742
    Likes Received:
    1
    i looked through the scar color functions, but i cant seem to make it properly...

    what i'm trying to do is monitor a specific pixel e.g. (200,200) which is a specific color e.g. 7915477.
    when that pixel changes color to any other color which is not its original color, the script should do a keydown.

    my question is, how to script the color action? it seems to me that scar can only detect when a pixel changes into a specific color, and not when it changes into any other color. there doesnt seem to be a 'not' function in scar for saying 'any color except ____' x.x

    someone please help? preferably post the one or two lines of script necessary to do this? thanks :D
     
  2. tharoux

    tharoux Level IV

    Joined:
    Dec 30, 2006
    Messages:
    2,733
    Likes Received:
    126
    Location:
    In front of my PC, Montreal
    Hi !
    So actually, I've just wrote 2 simple way of doing what you want:
    In a loop, the loop monitoring if the color in 200,200 is still 7915477, as soon as the color change, it perform the action keydown
    Code (Text):
    1. <div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">while(getcolor(40,40)=7915477)do</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">begin</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> Wait(250);</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">end;</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">keydown(x);</li></ol></div>
    and you can infact use "not" directly in your script and it should work, like this:
    Code (Text):
    1. <div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">If not(getcolor(200,200) = &nbsp;7915477)then</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">begin</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; keydown(x);</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">end;</li></ol></div>
    let me know if you need more help !
     
  3. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    nice one tharoux,
    deathcraze, this seems to be exactly what you are looking for and both of these methods work
    i prefer the second one but they both do the same things
     
  4. tharoux

    tharoux Level IV

    Joined:
    Dec 30, 2006
    Messages:
    2,733
    Likes Received:
    126
    Location:
    In front of my PC, Montreal
    I do prefer the second method too...
    Try to avoid as much infinite loop as possible.
     
  5. jazzeh

    jazzeh Level I

    Joined:
    Jan 1, 2008
    Messages:
    144
    Likes Received:
    15
    I don't really like getColor so I prefer something like:

    Code (Text):
    1. <div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> If (findcolor(x,y,7915477,200,200,200,200) = False) then</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">begin</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; keydown(x);</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">end; </li></ol></div>
    I actually use that on my darblat script
     
  6. deathcraze

    deathcraze Level III

    Joined:
    Mar 3, 2007
    Messages:
    742
    Likes Received:
    1

    thank you so so so much tharoux! i really appreciate it :D
    both methods seem to average around the same score when used on a flash game... though method 2 seems to give more 'consistent' scores o_O
    never knew function 'not' could be used in scar too.. this will make future scripts much easier.. thanks again!!