SRL Archive - First Scripts

small issue first script


fluffee

2014-06-25 11:33:45

Hey guys,
I'm having a little issue with a very simple script i'm making.
It basicly just needs to search for the color of the lifebar and then click a monk.
I keep getting this error though:
"Exception in Script: Invalid evaluation at line 9, column 70"

program monkkiller;

Procedure ClickMonk;
var
x, y :Integer;
begin;
if FindColorSpiralTolerance(x, y, 65280, 1, 1, 511, 336, 5) then
begin;
FindColorSpiralTolerance(x, y, 2106718, 1, 1, 511, 336, 5) or;
FindColorSpiralTolerance(x, y, 3817636, 1, 1, 511, 336, 5) or;
FindColorSpiralTolerance(x, y, 3422867, 1, 1, 511, 336, 5) then;
MoveMouse (x, y);
wait(200)
ClickMouse(x, y, 1);
wait(1000);
end;
end;

begin
repeat
ClickMonk;
until(false);
end.

I'm very new to this stuff so would you guys mind taking a look? :D
Thanks.

KeepBotting

2014-06-25 11:35:50

I'm guessing line 9 is
FindColorSpiralTolerance(x, y, 2106718, 1, 1, 511, 336, 5) or;

try removing the semicolons after your or statements

Ian

2014-06-25 11:36:42

You also shouldn't put semicolons after a begin.
Wrong:

begin;
Right:

begin

Haxz

2014-06-25 11:37:32

You don't put semicolon behind or. No semicolon behind begin as well. As for mouse clicking, its better for you to use Mouse function.

masterBB

2014-06-25 11:41:05

program monkkiller;

Procedure ClickMonk;
var
x, y :Integer;
begin
if FindColorSpiralTolerance(x, y, 65280, 1, 1, 511, 336, 5) or
FindColorSpiralTolerance(x, y, 2106718, 1, 1, 511, 336, 5) or
FindColorSpiralTolerance(x, y, 3817636, 1, 1, 511, 336, 5) or
FindColorSpiralTolerance(x, y, 3422867, 1, 1, 511, 336, 5) then
begin
MoveMouse (x, y);
wait(200)
ClickMouse(x, y, 1);
wait(1000);
end; //end of if x then begin...end
end; //end of procedure ClickMonk

begin
repeat
ClickMonk;
until(false);
end.

Fixed it properly.

All those or statements were outside an if statement.

fluffee

2014-06-25 11:52:18

Thanks!
But doesn't he constantly click the monk now, without checking for the colour of the life bar?
I actually just need it to click if he can't find that colour, but i'm not really sure how to implement that.

EDIT: Also thank you to everyone else trying to help me here. :P

KeepBotting

2014-06-25 12:05:27

From: fluffee
Thanks!
But doesn't he constantly click the monk now, without checking for the colour of the life bar?
I actually just need it to click if he can't find that colour, but i'm not really sure how to implement that.

EDIT: Also thank you to everyone else trying to help me here. :P

program monkkiller;

Procedure ClickMonk;
var
x, y :Integer;
begin
if FindColorSpiralTolerance(x, y, 65280, 1, 1, 511, 336, 5) then
if FindColorSpiralTolerance(x, y, 2106718, 1, 1, 511, 336, 5) or
FindColorSpiralTolerance(x, y, 3817636, 1, 1, 511, 336, 5) or
FindColorSpiralTolerance(x, y, 3422867, 1, 1, 511, 336, 5) then
begin
MoveMouse (x, y);
wait(200)
ClickMouse(x, y, 1);
wait(1000);
end; //end of if x then begin...end
end; //end of procedure ClickMonk

begin
repeat
ClickMonk;
until(false);
end.

Fixed masterBB's fix. That should do it.

also I recommend you look into mainScreen.findObject() for faster and more accurate object finding.

Ian

2014-06-25 12:05:32

From: fluffee
Thanks!
But doesn't he constantly click the monk now, without checking for the colour of the life bar?
I actually just need it to click if he can't find that colour, but i'm not really sure how to implement that.

EDIT: Also thank you to everyone else trying to help me here. :P


Consider having a new function to check the colour, like


function foundLifeBarColor: Boolean; //returns true if the LifeBarColor is found.
begin
result:= FindColorSpiralTolerance(...); //replace the FindColorSpiralTolerance(...) with the actual one.
end;

and then in your script you could have

if (not foundLifeBarColor) then
clickMonk;

And clickMonk could be just a procedure/function to click the monk.

fluffee

2014-06-25 12:19:33

I got it running. :D
I used KeepBotting's adjustment and replaced the "if" with "if not" on the first colourfinder, and now it basicly does what I want. ;)
It's just for a small simple private server, so I don't really need more accurate object finding atm.
Thanks!