Updated, 1/31/06 due to SRL changes. RAWRR.
Adding Randoms to Your Scripts By WhiteShadow
This tutorial will cover how and where to add randoms to your scripts.
Alright, so you first have to include the include. Obviously :
SCAR Code:
program New;
{.include SRL/SRL.Scar}
begin
SetUpSRL; //Loads
end.
There now you have access to all the functions in SRL's core folder. Thankfully the only function you need to call is FindNormalRandoms; Since it summed all the randoms up for you already..
SCAR Code:
{*******************************************************************************
function FindNormalRandoms: Boolean;
by: The SRL Developers Team!... all time sexiness by Mutant
Description: Calls the 'normal' random checks.
*******************************************************************************}
function FindNormalRandoms: Boolean;
var
i: Integer;
begin
for i := 1 to 16 do
begin
case I of
1: CloseWindow;
2: if FindTalk then
Result := True;
3: if FindDead then
Result := True;
4: if FindMod then
Result := True;
5: if FindMime then
Result := True;
6: if FindMaze then
Result := True;
7: if FindQuiz then
Result := True;
8: if FindDemon then
Result := True;
9: if FindScapeRune then
Result := True;
10: if FindTalk then // Call it twice
Result := True;
11: if FindLamp(LampSkill) then // Maybe we missed it?
Result := True;
12: if (FindNewBox) then
begin
Result := True;
if (UseBoxSolver) then
SolveBox
else
GambleNewBox;
end;
13: if FindTrade then
Result := True;
14:
begin
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
end;
15: SaveToChatLog;
16: if RC then
Result := True;
end;
Wait(1);
end;
end;
Before that though, I want you all to know something.
Nick, is important, very important. Why? Because your going to get ownd by randoms the whole time, and then complain about how SRL doesn't solve randoms correctly. All talking randoms are solved by looking for a bitmap mask of your Nick in the mainscreen!
What is Nick?! It's 3 - 4 letters of your username, so if my username was Isamcool then a good Nick would be amco. Yeah so grab a 3 -4 letter chunk out of the center of your username.
Here's one way to set nicks. Multiple player preferably. So DeclarePlayers; saves all the information on the characters. Then you use LoginPlayer, thankfully LoginPlayer; creates the bitmapmask of the Nick everytime you use it, so this is all you need to do.
SCAR Code:
program New;
{.include SRL/SRL.Scar}
procedure DeclarePlayers;
begin
HowManyPlayers := 1; //Number of players
NumberOfPlayers(HowManyPlayers);
CurrentPlayer:= 0;
Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
end;
begin
SetUpSRL;
DeclarePlayers;
LoginPlayer;
end.
Then there's also just this.
SCAR Code:
program New;
{.include SRL/SRL.Scar}
const
Nickk = 'ern';
begin
SetUpSRL;
NickNameBMP := CreateBitmapMaskFromText(Nickk, UpChars);
end.
Create the bitmapmask of the current player's Nick with the variable NickNameBMP. That's all that matters.
After all the setup with the includes, and Nicks just call FindNormalRandoms everywhere you see needed.
Bits
SCAR Code:
procedure WaitisChopping;
begin
while(Chopping)do
begin
Wait(200);
FindNormalRandoms;
end;
end;
procedure WaitisMining;
var
TimeMark : Integer;
begin
MarkTime(TimeMark);
repeat
Wait(200);
FindNormalRandoms;
if(TimeFromMark(TimeMark) > 30000)then
Exit;
until(isChatMessage('succ'))
end;
Never not call FindNormalRandoms in a 2 second range. You should always have your script scanning for randoms continously for best results.
The END.
Sorry, I'm rly busy atm. Quick-wrte, eeek. :P