Lighty Posted December 7, 2011 Share Posted December 7, 2011 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. Quote Link to comment Share on other sites More sharing options...
FHannes Posted December 7, 2011 Share Posted December 7, 2011 I'm not sure what you're asking, going by your question I'd say you got it pretty much right aside fromt he fact it should be "x-50, y-50, x+50, y+50"... Quote Link to comment Share on other sites More sharing options...
Lighty Posted December 7, 2011 Author Share Posted December 7, 2011 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; Quote Link to comment Share on other sites More sharing options...
FHannes Posted December 7, 2011 Share Posted December 7, 2011 You should swap them around "x-30, y-30, x+30, y+30", is this a script for RuneScape? Quote Link to comment Share on other sites More sharing options...
Lighty Posted December 7, 2011 Author Share Posted December 7, 2011 (edited) 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 December 7, 2011 by Lighty Quote Link to comment Share on other sites More sharing options...