g0tp0t
2010-07-07 15:54:38
im getting this error:
with this code:
I havent been able to figure out whats wrong :\
Successfully compiled (1924 ms)
SRL Compiled in 15 msec
Begining Main Loop :D
[Runtime Error] : Out Of Range in line 69 in script C:\Users\josh\Desktop\Clay Softener.scarwith this code:
{.include srl/srl.scar}
{$Define DebugMyScript}
var
x,y,i,ii,BankerR,BankerG,BankerB,BankerR2,
BankerRMid,BankerGMid,BankerBMid,BankerG2,
BankerB2,ClayDTM,HumidifyDTM,SoftDTM,casts:integer;
ClayPoint,CenterScreen,ClosestBanker:Tpoint;
BankerLight,BankerDark,BMidCol:TColor;
BankerTPA,CentersOfBankers:TpointArray;
Bankers:t2dPointArray;
const // | ^This is an array of TPA's :D
HowManyCasts = 154;
Start_Items = 2; // ^ A TPointArray or 'TPA' is just an array of coordinates/Points
procedure DeclareStuff;
begin //<-dont capitalize the first letter of bold words. Only Dot that with variables, constants, functions, and procedures;
ClayDTM := DTMFromString('78DA63CC65626060676440054C601226CA980' + //<-I will explain dtm's seperatly :D lol :P
'2E47312A18697809A02209F87809A6222ECCA03F29908A8C902F2' +
'0588B08B15BF1A0069D203E5');
HumidifyDTM := DTMFromString('78DA63B4626260606664C00660A28CE64035D' +
'F19F0ABB105AAF949408D2B50CD7F026AF4816A9808B8C710A8E6' +
'1F01732C806A780898630A54C345408D03500D277E3500EF19063' +
'B');
SoftDTM := DTMFromString('78DA634C63626050666440054C601226CA980' +
'7E49B13505305E46B1250530AE41B1350930AE49B11509304E4EB' +
'E2570300D58003CE');
end;
Function GetBankerMidCol:TColor; //<--the type 'TColor' as a number that represents a color
begin
ColortoRGB(BankerLight,BankerR,BankerG,BankerB); //Split the lighter Banker Color into RGB
ColortoRGB(BankerDark,BankerR2,BankerG2,BankerB2);//Split the Darker Banker Color into RGB
BankerRMid := (BankerR+BankerR2)/2; //<-\
BankerGMid := (BankerG+BankerG2)/2; //<---Average each color chanel individually to get a
BankerBMid := (BankerB+BankerB2)/2; //<-/ color exactly between BankerLight and BankerDark
result := RGBtoColor(BankerRMid,BankerGMid,BankerBMid)
//^Merge all the averaged color chanels into the new Banker color
end;
Function GetClosestPoint(TPointToCompare:TPoint; TPointArrayToSearch:TPointArray):TPoint;
var lowest:integer;
begin
for i := 0 to length(TPointArrayToSearch)-1 do
lowest := Min(lowest, Distance(TPointToCompare.x,TPointToCompare.y,TPointArrayToSearch[i].x,TPointArrayToSearch[i].y));
for ii := 0 to length(TPointArrayToSearch)-1 do
if Distance(TPointToCompare.x,TPointToCompare.y,TPointArrayToSearch[ii].x,TPointArrayToSearch[ii].y)=lowest then
result := TPointArrayToSearch[ii];
end;
procedure WithdrawClay;
begin
if not bankscreen then // If bank screen is not visible then...
begin //open bank
BMidCol := GetBankerMidCol // Notice that I decalare GetBankerMidCol before I call it >.<
FindColorsSpiralTolerance(MSCX,MSCY,BankerTPA,BMidCol,MSX1,MSY1,MSX2,MSY2,min(gettolerance(BMidCol,BankerLight),gettolerance(BMidCol,BankerDark))-1)
Bankers := SplitTPA(BankerTpa,40)
for i := 0 to length(bankers)-1 do
begin //^-I need that -1 because the array starts at 0 and not 1
CentersOfBankers[i] := MiddleTPA(Bankers[i])
end;
CenterScreen.x := MSCX
CenterScreen.y := MSCY
ClosestBanker := GetClosestPoint(CenterScreen,CentersOfBankers)
{$IfDef DebugMyScript}
WriteLn('Clicking Banker');
If iskeydown('`') then terminatescript;
{$EndIf}
Mouse(ClosestBanker.x,ClosestBanker.y,5,5,false);
ChooseOption('Bank ');
end;
WriteLn('Bank has been opened :D');
FindDTM(ClayDTM,x,y,MSX1,MSY1,MSX2,MSY2);
ClayPoint.x := x
ClayPoint.y := y
ClayPoint := MSTPointToBankPoint(ClayPoint)
{$IfDef DebugMyScript}
WriteLn('Withdrawing');
If iskeydown('`') then terminatescript;
{$EndIf}
withdraw(ClayPoint.x,ClayPoint.y,0);
if BankScreen then
CloseBank
else
addtoreport('Bank was already closed when attempting to close the bank...')
end;
Procedure Humidify;
begin
GameTab(Tab_Magic)
FindDTM(HumidifyDTM,x,y,MIX1,MIY1,MIX2,MIY2)
{$IfDef DebugMyScript}
WriteLn('Clicking Humidify');
If iskeydown('`') then terminatescript;
{$EndIf}
Mouse(x,y,3,3,true)
WriteLn('OMG!! A rainstorm!! :D');
Wait(1000+Random(Random(125))); //A random in a random?? LEts see if you can figure out what that will do
WriteLn('Storms Over :''{'); //The random function just returns a number from 0 to Whatever-Number-You-Put-In-The-Parenthisis
inc(casts); //^Ther are two of those half-quotaion marks because i want writeln to print the string "Storms over :'{"
end; // Normally the ' mark will start or end a string. by putting two together you get a ' inside the string
(* <- those parenthesis with asterisks are block comments
They make it so i dont have to use the // before every comment i write
the { and } does the same thing :D
OMFG!!!!!!!!! Script ended :'{'''''''
*)
var BlackPoints:integer
begin
setupsrl;
repeat
{$IfDef DebugMyScript}
WriteLn('Begining Main Loop :D');
If iskeydown('`') then terminatescript;
{$EndIf}
if CountItemsBlackLine(BlackPoints,3) > Start_Items then
Humidify
else
WithdrawClay;
Until Casts >=howmanycasts;
end.
I havent been able to figure out whats wrong :\