SRL Archive - First Scripts

Clicks backpack before my script does anything


g0tp0t

2010-07-07 02:48:36

When i run this the mouse just keep clicking the backpack, i get no messages, and my script writes a message everytime it moves the mouse -.-

{.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 :'{'''''''

*)

begin
setupsrl;
repeat
if invcount > Start_Items then
Humidify
else
WithdrawClay;
Until Casts >=howmanycasts;
end.

Frement

2010-07-07 02:55:33

I think its because your invcount.

g0tp0t

2010-07-07 03:47:49

ooh, didnt think of that, it clicks even when inv is already open though :\

Cigue

2010-07-07 03:53:40

Hey man, if you're making an humidifier, I already got one you could get ideas from :) I haven't updated it in 6 months, but the stuff in it is very solid. Just check out my signature !

g0tp0t

2010-07-07 03:57:36

lol. your color is red but i dont see humidifier. ill search for Your script 2moro :P thanks for telling me about it. i really should have thought to find another humidifier :P

ShowerThoughts

2010-07-07 05:32:55

I didn't check your script but maybe you are looking for randoms? If you check for Randoms(SRL) then it will auto check the inventory tab, you could use findnoninventoryrandoms.

Frement

2010-07-07 05:35:43

He doesn't have random checks there, checked that already :)

g0tp0t

2010-07-07 12:30:40

yea, randoms was the first thing that seemed to give problems when debugging users chimp script. Also, i couldt fix that chimoo script because it seems like uptext is borken, i know it was broken a while ago but has it been fixed?

Alos that script isnt done and has no failsafes :P just so noone says anything lol.