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.
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.