Log in

View Full Version : Need help understanding



Reveille
01-14-2012, 03:34 AM
I'm gradually learning how to script, I've read most of the tutorials in the beginner and a few in the intermediate. I'm also reading scripts as reference. I just finished reading PatDuffy's Firemaking script "Burning Down da House". I understand most of the script but can someone explain to me a few lines? I included the entire procedure but the only part I don't understand is the if (TPA[I].y)=(TPA[I+1].y) then part in the alternative method.

Procedure tobank;
Var
TPA:TPointArray;
ATPA:T2DPointArray;
L,S,I:Integer;
Begin
GetNewRoadColor(mmx1,mmy1,mmx2,mmy2,6);
repeat
findnormalrandoms;
RadialRoadWalk(RoadColor,80,110,70,-2,0);
writeln('Walking to bank. The roadcolor is:'+inttostr(roadcolor)+'.');
if kill=3 then
begin
writeln('Walking to bank failed, logging out...');
logout;
TerminateScript;
end;
inc(kill);
writeln(countdots('yellow'));
until findsymbol(x,y,'bank') Or (CountDots('yellow') > 10)
//bank
kill:=0;
wait(RandomRange(1000,1000));
writeln(countdots('yellow'));
if findsymbol(x,y,'bank') then
writeln('using bank symbol')else
begin
writeln('using alternate method');
TPA:=GetMinimapDotsIn('yellow', MMX1, MMY1, MMX2, MMY2);
L:=length(TPA);
S:=0;
I:=0;
repeat
inc(I);
if (TPA[I].y)=(TPA[I+1].y) then
if (TPA[I].y)=(TPA[I+2].y) then
S:=I;
until S>0
writeln(S)
writeln(TPA);
x:=TPA[S].x
y:=TPA[S].y
end;
mouse(x,y,7,7,true);
wait(RandomRange(8000,9000));
End;

Mark
01-14-2012, 03:38 AM
it changes the points to each of the yellow minimap dots to find a banker im guessing

Reveille
01-14-2012, 03:41 AM
Well I get that it finds coordinates from the yellow dots but I haven't seen "if (TPA[I].y)=(TPA[I+1].y) then" before and don't know how it's used with the integers

Mark
01-14-2012, 03:47 AM
there are different types
TPoint
TPointArray
TBox
TStringArray

the one he uses to specify a point to click x , y
Mouse(tpa.x,tpa.y,5,5,Mouse_left);

you should look up a TPA tutorial

Reveille
01-14-2012, 03:50 AM
Yeah that's one area I really lack in, also radial walking. I'll look for one but in case I don't find the TPA tutorial can you post a link?

Brandon
01-14-2012, 03:51 AM
left side = right side.. it's checking the y co-ordinates.. if the Y-coordinate in the TPA = the next Y coordinate in the tpa then... continue on..

Consider your TPA to be:

[Point(1, 2), Point(2, 3), Point(3, 4), Point(1, 4)]

It's doing: if (2 = 3) then.. if (3 = 4) then.. if (4 = 4) then... <--- Those are all Y values of each point in the TPA.. First point's y = 2, second = 3, third = 4, fourth = 4.. Comparing them to the one after it.

Mark
01-14-2012, 03:51 AM
just a quick look
http://villavu.com/forum/showthread.php?t=21786

Reveille
01-14-2012, 04:06 AM
I'm about to read the tutorial then I'll have a better understanding. I understand your explanation, but what you're saying ggzz is that all the bankers are in a line on the same y points and it's a check to see if those are the yellow dots to look for?

Brandon
01-14-2012, 04:51 AM
I'm about to read the tutorial then I'll have a better understanding. I understand your explanation, but what you're saying ggzz is that all the bankers are in a line on the same y points and it's a check to see if those are the yellow dots to look for?

Yes.. That is the only reason someone would compare just the Y values alone.. That means they assume that all the X values are the same.. Later in the script you can see that when the y values do equal and it does find multiple bankers in a line, it uses that point where it's found to click it:


x:=TPA[S].x
y:=TPA[S].y


I wouldn't use that procedure if I were you.. It does not check for the length of the array to exit failsafe.. plus lets say the first value does match.. and it hits the last point.. it seems to just do a TPA[I + 2].. if I is the last value and it tries to get another value > I then bam.. exception thrown for accessing values that don't exist?

There's other banking functions you should look at such as the ones in the include.

Reveille
01-14-2012, 06:05 AM
One last question, what is the link for the SRL includes. I've found it a few times to reference stuff but forgot to bookmark it. Haven't been able to find it again.

Mark
01-14-2012, 02:09 PM
I'm on my phone atm so I will update. This post later on with the link.

But for now click on includes in your function list
To see a list of functions. Double click any function to get see how its written and how to use it