Jump to content
Lighty

Increments and Decrements on variables

Recommended Posts

Hi,

 

I am writing a script that uses colour recognition to find and click things. Now with one colour there is often many matches to that colour so I have added another 'if' to ensure it clicks what it should.

 

What I cannot think of how to do is: for my second if statement within the procedure, I want it to search between the variables x and y (which are set in the first if statement) but I want to search within x+50, x-50 and y+50, y-50 (x and y are both integers).

 

How do I incorporate this into my if statement?

 

Here is my current section of code (part of a procedure):

 

var
x, y : Integer;
 begin
 if FindColor(x, y, 2767171, 151, 106, 335, 227) then
    if FindColor(x, y, 2634547, x-50, y-50, x+50, y-50) then
     ClickMouse(x, y, true);
     Wait(1000 + Random(500));
 end;

 

I have inserted the x+50, y+50 for illustration purposes. I want to find the correct way of doing this.

 

Thanks.

Link to comment
Share on other sites

I've made the corrections but for some reason it's not clicking anything. The colour codes are correct as nothing has changed (e.g. camera angle). Here's the procedure:

 

procedure ClickNPC;
var
 x, y, a, b : Integer;

 begin
 if FindColor(x, y, 3491141, 151, 106, 335, 227) then
   if FindColor(a, b, 2766390, x+30, y+30, x-30, y-30) then
   ClickMouse(x, y, true);
   Wait(1000 + Random(500));
 end;

Link to comment
Share on other sites

You should swap them around "x-30, y-30, x+30, y+30", is this a script for RuneScape?

 

I have tried them the other way. Yes, for a RSPS.

 

UPDATE: I have managed to get it clicking, thanks for the help.

Edited by Lighty
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...