Hi,
Is there in MoHAA scripting language a 'case' type command? I mean, a command that does another thing when a variable has another value. In Turbo Pascal there was something like this (here I coloured the code like TP's editor would do):
case variable of
1: writeln("Variable''s value = 1");
2: writeln("Variable''s value = 2");
etc. etc.
end;
I think you know what I mean. I tried to do something with switch, but it gave a strange effect, maybe I did something wrong.
Rookie One
'Case of'?
Moderator: Moderators
-
Rookie One.pl
- Site Admin
- Posts: 2752
- Joined: Fri Jan 31, 2003 7:49 pm
- Location: Nowa Wies Tworoska, Poland
- Contact:
-
Innkeeper
- Colonel
- Posts: 475
- Joined: Mon Nov 25, 2002 10:13 pm
- Location: NC, USA (about 7.5 klicks from the capital dome)
- Contact:
The switch stament should be written like this:
Code: Select all
switch(variable)
{
case 1: writeln("Variable's value = 1")
break
case 2: writeln("Variable's value = 2")
break
}
Innkeeper - moderator
<img src="http://www.planetmedalofhonor.com/map/layoutimages/banner.jpg" border="0" />
Buy the best and cry only once
<img src="http://www.planetmedalofhonor.com/map/layoutimages/banner.jpg" border="0" />
Buy the best and cry only once
writeln really should be println 
You may also use a label instead of a case, to check for a string.
For instance:

You may also use a label instead of a case, to check for a string.
For instance:
Code: Select all
switch(self.position)
{
stand:
println "standing :)"
break
crouch:
println "crouching :|"
break
pain:
println "ouch :("
break
default:
println "what the hell am I doing :S"
}
-
Innkeeper
- Colonel
- Posts: 475
- Joined: Mon Nov 25, 2002 10:13 pm
- Location: NC, USA (about 7.5 klicks from the capital dome)
- Contact:
Innkeeper - moderator
<img src="http://www.planetmedalofhonor.com/map/layoutimages/banner.jpg" border="0" />
Buy the best and cry only once
<img src="http://www.planetmedalofhonor.com/map/layoutimages/banner.jpg" border="0" />
Buy the best and cry only once
-
Rookie One.pl
- Site Admin
- Posts: 2752
- Joined: Fri Jan 31, 2003 7:49 pm
- Location: Nowa Wies Tworoska, Poland
- Contact:
:)
Thanks 8) .


