Main Loop example (single player, just wrap another loop around for multi)
Code:
var errors:integer;
begin
SetupScript;
repeat
//yea i know, not indented, but it looks neater this way
if ToTanShop then
if ToEllis then
if FindEllis then
if TanHides then
if ToBank then
if FindBankers then
if MyOpenBank then
if DepositLeathers then
errors:=0;
errors:=errors+1;
if errors>4 then
Reset;
until(Players[CurrentPlayer].Integers[0]<(TannedLeather));
end.
Example of a function
Code:
function ToEllis:boolean;
var yellows,yellows3:tpointarray;
var tmpx,tmpy:integer;
begin
if not loggedin then exit;
writeln('ToEllis-Start');
if HaveLeathers or TanScreen then
begin
writeln('ToEllis-Already done tanning, true')
result:=true;
exit;
end;
if not FindSymbolIn(tmpx,tmpy,'tanner',mmx1,34,mmx2,mmy2)then
if not FindSymbolIn(tmpx,tmpy,'furnace',mmx1,53,mmx2,mmy2) then
begin
writeln('ToEllis-Cant find tannery or furnace, false');
result:=false;
exit;
end;
if FindSymbolIn(tmpx,tmpy,'tanner',mmx1,34,mmx2,mmy2)then
begin
FindColorsTolerance(yellows,195836,mmx1,mmy1,mmx2,mmy2,0);
writeln(inttostr(getarraylength(yellows))+' yellow pixels');
yellows3:=ReArrangeandShortenArrayEx(yellows,4,4);
writeln(inttostr(getarraylength(yellows3))+' yellow dots');
SortTPAFrom(yellows3,IntToPoint(tmpx,tmpy));
setarraylength(yellows3,2);
SortTPAFrom(yellows3,IntToPoint(mmx2,mmcy));
Mouse(yellows3[0].x,yellows3[0].y,1,1,true);
highestangle;
fflag(0);
end;
if HaveLeathers or TanScreen then
begin
writeln('ToEllis-Already done tanning, true')
result:=true;
exit;
end;
result:=true;
end;
Which has a bunch of checks to what stage it is at using stuff like this
Code:
function HaveLeathers:boolean;
var tmpx,tmpy:integer;
begin
gametab(4);
if not FindDTM(HideDTM,tmpx,tmpy,mix1,miy1,mix2,miy2) then
exit;
if getcolor(tmpx+2,tmpy+4)=getcolor(tmpx+2,tmpy+5) then
result:=true;
end;
This set up was especially useful for me during testing and development, because I was restarting the script after making an edit many times, and this way I didn't have to reset back at the bank every time, it can just pick up at any point.