PDA

View Full Version : Using Case and Of



Fourscape
05-05-2007, 10:19 PM
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
06-03-2007, 04:46 AM
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
06-03-2007, 07:18 AM
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
08-18-2007, 08:40 PM
very nice ill hav 2 add to my script im making
ty heaps