PDA

View Full Version : Guide on Cases



camdo2
11-04-2007, 04:07 AM
First off I would like to thank floor66 for teaching me on cases for my old script.

What is a case?

A case is like a procedure that does something like picking one of the choices you give it out of a hat. That's the very basics. I will now tell you how to begin your case.


Program CaseTUT;
begin
case random(2) of

0: begin
Writeln('good job');
end;
1: begin
Writeln('learning on cases');
end;
end;
end;


Let's look at each of these things:

random(2) means that the number in the parenthesis will be the number of options that you put in the case.
0: is the first option
1: is the second option

But this kind of thing can be used for many reasons which all of them I don't know. One I know of though is an auto typer can pick random sentences. There is also a function I believe named FindFastRandoms that uses cases too.

If you put a loop in here, it will keep repeating the picking of a hat. Like this...

program loopcasetut;
begin
repeat
case random(3) of
0: begin
Writeln('good job');
end;
1: begin
Writeln('learning on cases');
end;
2: begin
Writeln('so far');
end;
end;
until(false);
end;


okay... We know that the repeat in bold is repeat and the until(false) at the end will repeat the case forever! The only thing I changed about this is that the number in the random() is instead of 2 it's 3. What this will do instead of the program having two choices to pick from it will have three.


I hope this helps...

-Camdo Clark

kingy101
11-04-2007, 04:23 AM
wow thanks for this =)

camdo2
11-04-2007, 04:24 AM
wow thanks for this =)

Thanks, can you rep me?

Dan Cardin
11-04-2007, 01:09 PM
ur not supposed to ask for rep, and it should be
Program CaseTUT;
begin
case random(2) of

0: begin
Writeln('good job');
end;
1: begin
Writeln('learning on cases');
end;
end;
end.

i think you could go into more detail.

ShowerThoughts
11-04-2007, 01:14 PM
like case whichLeather of ;)

edit:

like:

procedure Choose;
begin
case EndSkill of
1, 2, 3, 4, 5, 6: ItemToCraft := 'gloves';
7, 8: ItemToCraft := 'boots';
9, 10: ItemToCraft := 'cowl';
11, 12, 13: ItemToCraft := 'vambraces';
14, 15, 16, 17: ItemToCraft := 'body';
18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50: ItemToCraft := 'chaps';
end;
end;

procedure PickXandY;
begin
case ItemTocraft of
'gloves':begin
XItem := 191;
Yitem := 117;
end;
'boots': begin
XItem := 316;
Yitem := 114;
end;
'cowl': begin
XItem := 382;
Yitem := 234;
end;
'vambraces': begin
XItem := 445;
Yitem := 247;
end;
'body': begin
XItem := 72;
Yitem := 109;
end;
'chaps': begin
XItem := 126;
Yitem := 247;
end;
end;
end;

ps. endskill is your level(crafting level)

camdo2
11-04-2007, 02:46 PM
Thanks, I'll add that. Oh and thanks Dan Cardin for telling me that you shouldn't ask for rep.

ShowerThoughts
11-04-2007, 02:52 PM
btw, the rep system is out of air they didnt like it ;)

camdo2
11-04-2007, 03:03 PM
Really i thought it was one of the ways to become a junior member like the tut for becoming one said.

P.S. I added a little more please more feedback.

camdo2
11-04-2007, 03:24 PM
Has anyone else tried this?

simple skill
09-22-2008, 07:54 PM
rep ++ thanks that helped