Log in

View Full Version : Multiple Actions in case..of?



Abu
03-19-2012, 09:53 PM
Hi, I'm trying to update my script and I was wondering if there was any way to do two actions in one case.

For Example

procedure example;
begin
case Random(160) of

1: Action1, Action 2;

2: Action1, Action 3;

3: Action1, Action 4;

4: Action1, Action 5;
end;
end;



For 'Action 1' I simply want to write text on screen(I know how) while performing the action of that case. However, every time I do this it asks me to put the other Action on a separate line. Though I can use the same case for that action, it will always pick the one above it. for example:
begin
case Random(160) of

1: Action 1; // will always do this is case 1 is picked
1: Action 2; // but never this

2: Action 1; // will always do this is case 2 is picked
2: Action 2; // but never this

Try to understand I ONLY want Action 1 performed while doing the other Action , so there's no point putting it at the start of the procedure because if none of the cases are picked, the on-screen text will be useless.


NEVERMIND SOLUTION FOUND. THANKS

Kyle Undefined
03-19-2012, 09:58 PM
Like this?


procedure example;
begin
case(Random(160))of
1: begin
Action1, Action 2;
end;

2: begin
Action1, Action 3;
end;

3: begin
Action1, Action 4;
end;

4: begin
Action1, Action 5;
end;
end;
end;

Abu
03-19-2012, 10:01 PM
I'll try that and get back to you

Valithor
03-19-2012, 10:11 PM
Try to understand I ONLY want Action 1 performed while doing the other Action

Wouldn't another idea be to code something like... ?

procedure example;
begin
case Random(160) of

1: while Action1 do Action 2;

2: while Action1 do Action 3;

3: while Action1 do Action 4;

4: while Action1 do Action 5;
end;
end;

bolshak25
03-19-2012, 10:16 PM
procedure example;
begin
case Random(160) of

1: begin Action1; Action 2; end;

2: begin Action1; Action 3; end;

3: begin Action1; Action 4; end;

4: begin Action1; Action 5; end;
end;
end;

Abu
03-19-2012, 10:22 PM
None of those work for me. Here I'll post a program on what I'm trying to do:

program New;
{$DEFINE SMART}
{$i srl\srl.simba}


procedure BreakText;
begin
SMART_DrawText(276,285,UpCharsEx,'Dont Worry, Just Taking A Human-Like Break...',clTeal);
end;


procedure MiniBreak;
begin
case(Random(160))of
1: begin BreakText, Wait(40000 + random(7400)) end

2: begin BreakText, Wait(25500 + random(8550)) end

3: begin BreakText, Wait(60040 + random(6759)) end

4: begin BreakText, Wait(20400 + random(2549)) end
end;
end;
end;


begin
ClearDebug;
SetUpSRL;
MiniBreak;
end.

The procedure 'BreakText' compiles just fine.

Could someone play around with the 'Minibreak procedure' and try to get it to compile?

Yago
03-19-2012, 10:24 PM
None of those work for me. Here I'll post a program on what I'm trying to do:

program New;
{$DEFINE SMART}
{$i srl\srl.simba}


procedure BreakText;
begin
SMART_DrawText(276,285,UpCharsEx,'Dont Worry, Just Taking A Human-Like Break...',clTeal);
end;


procedure MiniBreak;
begin
case(Random(160))of
1: begin BreakText, Wait(40000 + random(7400)) end

2: begin BreakText, Wait(25500 + random(8550)) end

3: begin BreakText, Wait(60040 + random(6759)) end

4: begin BreakText, Wait(20400 + random(2549)) end
end;
end;
end;


begin
ClearDebug;
SetUpSRL;
MiniBreak;
end.

The procedure 'BreakText' compiles.

Could someone play around with this and try to get it to compile?

You're missing semicolons after breaktext and wait...

and after end;

Abu
03-19-2012, 10:26 PM
You're missing semicolons after breaktext and wait...

and after end;

My word I love your eyes!

Rep for you and rep for Bolshak!

eska
03-19-2012, 10:27 PM
procedure example;
begin
case Random(160) of
1:
begin
Action1;
Action 2;
end;

2:
begin
Action1;
Action 3;
end;

3:
begin
Action1;
Action 4;
end;

4:
begin
Action1;
Action 5;
end;
end;
end;


dem standards make it easier to find dem mistake like forgeting or putting too many end;

Abu
03-19-2012, 10:29 PM
Thanks but I've already figured it out.


Case closed. :norris:

masterBB
03-19-2012, 10:30 PM
procedure MiniBreak;
begin
case(Random(4))of
1: begin
BreakText;
Wait(40000 + random(7400));
end;

2: begin
BreakText;
Wait(25500 + random(8550));
end;

3: begin
BreakText;
Wait(60040 + random(6759));
end;

4: begin
BreakText;
Wait(20400 + random(2549));
end;
//removed one end;
end;
end;

edit:
ninja'd really hard :) I probably was just slow.

eska
03-19-2012, 10:31 PM
Case closed. :norris:

It looks like this case is..... Closed.
http://local-static2.forum-files.fobby.net/forum_attachments/0024/9212/csi_yeah_skyline_large.jpg

Had to do it.

Abu
03-19-2012, 10:33 PM
ninja'd really hard :) I probably was just slow.

I appreciate the effort :)