From: henryuscola
Here is what I have so far;function prayersOn(): boolean;
const
PRAYERS = 9222802;
begin
result := getColor(910, 118) = PRAYERS;
end;
procedure togglePrayer();
var
praybox: TBox;
begin
if PRAYERS = 0 then exit();
writeLn('Toggling prayers.');
praybox := intToBox(613, 83, 627, 92);
mouseBox(praybox, MOUSE_LEFT);
end;
function inCombat(): boolean;
var
x, y: integer;
box: Tbox;
begin
result := findColorTolerance(x, y, 50824, intToBox(256, 226, 528, 352), 5)
end;
function inFightarea(): boolean;
var
x, y: integer;
const
FF_COLOR = 2116475;
begin
if result := getColor(775, 286) = FF_COLOR then
begin
writeln('we are in fightarea now.............');
end;
end;
///then main loop
begin
repeat
if inFightarea and InCombat() and not prayersOn then togglePrayer until false
end.
I'd suggest trying something like this:
function prayersOn(): boolean;
const
PRAYERS = 9222802;
begin
result := getColor(910, 118) = PRAYERS;
Writeln('prayersOn Result : ' + toStr(Result)); // Debugging so you know if this function is working
end;
procedure togglePrayer();
var
praybox: TBox;
begin
if PRAYERS = 0 then exit();
writeLn('Toggling prayers.');
praybox := intToBox(613, 83, 627, 92);
mouseBox(praybox, MOUSE_LEFT);
end;
function inCombat(): boolean;
var
x, y: integer;
box: Tbox;
begin
result := findColorTolerance(x, y, 50824, intToBox(256, 226, 528, 352), 5)
Writeln('inCombat Result : ' + toStr(Result)); // Debugging so you know if this function is working
end;
function inFightarea(): boolean;
var
x, y: integer;
const
FF_COLOR = 2116475;
begin
if result := getColor(775, 286) = FF_COLOR then
writeln('we are in fightarea now.............');
end;
///then main loop
begin
repeat
if inFightarea and InCombat() and (not prayersOn) then
togglePrayer;
wait(randomRange(1000,2000)); // Insert a wait so that it isn't constantly checking and clicking
until (false);
end.
That should debug if something is broken, and will wait between checks. I assume there is a slight delay between clicking and the button changing color so you were probably not having enough delay and it just kept clicking over and over. Change the wait range if you'd like (it's currently 1-2 seconds).