SRL Archive - Outdated Tutorials

Using Case and Of


Fourscape

2007-05-05 18:19:46

Using the code
Case ' ' Of
Is very usefull in scripts. It makes it alot easyer to organize some code.

Take this for example. Your code may look like this.

Var
ColorOfOre : Integer;
Const
OreToMine = 1; // 1-Copper, 2-Tin, 3-Iron.

Procedure GetOreColor;
Begin
If (OreToMine = 1) then
Begin
OreColor := 1111111;
end else
If (OreToMine = 2) then
Begin
OreColor := 2222222;
end else
If (OreToMine = 3) then
Begin
OreColor := 3333333;
end;
end;

Using Case ' ' Of You could do this.

Var
ColorOfOre : Integer;
Const
OreToMine = 1; // 1-Copper, 2-Tin, 3-Iron.

Procedure GetOreColor;
Begin
Case OreToMine Of
1 : OreColor := 1111111;
2 : OreColor := 2222222;
3 : OreColor := 3333333;
end;
end;

Much easyer eh?

Or say you want a sweet antiban procedure… Why not use this?

Procedure Antibaning;
Begin
Case Random(100) of
1 : RandomRClick;
2 : GameTab(1 + Random(7));
3 : BoredHuman;
4 : AlmostLogOut;
5 : FTWait(5);
end;
end;

If the random number is 1-5, it will preform antiban.

Thats my short tutorial on how to use Case ' ' Of, hope it helps.

kooldude

2007-06-03 00:46:44

Nice Tut, Covers the basics of Case. :)

Procedure Antibaning;
Begin
Case Random(100) of //Shouldnt This Be Case Random(5) of
1 : RandomRClick;
2 : GameTab(1 + Random(7));
3 : BoredHuman;
4 : AlmostLogOut;
5 : FTWait(5);
end;
end;

Pentti

2007-06-03 03:18:57

From: kooldude
Nice Tut, Covers the basics of Case. :)

Procedure Antibaning;
Begin
Case Random(100) of //Shouldnt This Be Case Random(5) of
1 : RandomRClick;
2 : GameTab(1 + Random(7));
3 : BoredHuman;
4 : AlmostLogOut;
5 : FTWait(5);
end;
end;

Random(100) is because it randomly chooses if it will do antiban or not.

dark4mdawn

2007-08-18 16:40:40

very nice ill hav 2 add to my script im making
ty heaps