 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
Gizmog1 Don't Lurk In The Bushes!

Joined: 05 Mar 2003 Posts: 2257 Location: Lurking In The Bushes!
|
Posted: Fri Feb 15, 2008 3:37 pm Post subject: Question about "or" |
|
|
Suppose I want to check a group of values, 1-8. If 1,2,3 & 4 all equal 2, something happens. That same thing happens if 5,6,7 & 8 all equal 4. Can I put both these conditions into the same if statement like this:
Code: |
if (
V1==2,
and,
V2==2,
and,
V3==2,
and,
V4==2,
or,
V5==4,
and,
V6==4,
and,
V7==4,
and,
V8==4)
then (endoftheworldasweknowit) |
Or would that check if 1&2&3, 4 or 5, 6&7&8?
This is part of a pretty long and complicated script with a lot of if, then, else type deals going on, so having to do as few of them as possible is a priority. |
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Fri Feb 15, 2008 3:51 pm Post subject: Re: Question about "or" |
|
|
use parenthesis. I would write it more like this:
Code: | if ( (V1==2, and, V2==2, and, V3==2, and, V4==2),
or,
(V5==4, and, V6==4, and, V7==4, and, V8==4) )
then (endoftheworldasweknowit) |
of course, if you really want it slick and clean, just break the conditional into a separate script:
Code: |
script, is end of world, begin
if (V1==2, and, V2==2, and, V3==2, and, V4==2) then(exit returning(true))
if (V5==4, and, V6==4, and, V7==4, and, V8==4) then(exit returning(true))
exit returning(false)
end
plotsscript, whatever, begin
if(is end of world) then (endoftheworldasweknowit)
end
|
Yeah... that is what I would do. |
|
Back to top |
|
 |
Newbie_Power

Joined: 04 Sep 2006 Posts: 1762
|
Posted: Fri Feb 15, 2008 3:56 pm Post subject: Re: Question about "or" |
|
|
Code: |
script, is end of world, begin
if (V1==2, and, V2==2, and, V3==2, and, V4==2) then(exit returning(true))
if (V5==4, and, V6==4, and, V7==4, and, V8==4) then(exit returning(true))
exit returning(false)
end
plotsscript, whatever, begin
if(is end of world) then (endoftheworldasweknowit)
end
|
[/quote]This script is both useful (in being informative) and awesome at the same time. _________________
TheGiz> Am I the only one who likes to imagine that Elijah Wood's character in Back to the Future 2, the kid at the Wild Gunman machine in the Cafe 80's, is some future descendant of the AVGN? |
|
Back to top |
|
 |
Gizmog1 Don't Lurk In The Bushes!

Joined: 05 Mar 2003 Posts: 2257 Location: Lurking In The Bushes!
|
Posted: Fri Feb 15, 2008 4:02 pm Post subject: |
|
|
Holy cow! I never thought I'd get a useful answer in less than fifteen minutes. That has to be some kind of a record. A million thanks, that should work out perfectly. |
|
Back to top |
|
 |
Rya.Reisender Snippy

Joined: 18 Jan 2008 Posts: 821
|
Posted: Fri Feb 15, 2008 11:07 pm Post subject: |
|
|
That's a pretty good song. |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sat Feb 16, 2008 10:23 pm Post subject: |
|
|
Of course, you can always use && and || instead of ,and, and ,or, . In fact, you can write
Code: | if (
V1==2
&&
V2==2
&&
V3==2
&&
V4==2
||
V5==4
&&
V6==4
&&
V7==4
&&
V8==4)
then (endoftheworldasweknowit) |
and it'll do what you wanted (but using brackets is still a good idea) _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Raekuul Delicious!

Joined: 31 Mar 2004 Posts: 641 Location: Nowhere
|
Posted: Sun Feb 17, 2008 1:25 pm Post subject: |
|
|
So, those brax in JP's example are just like 'else's? _________________ A broken clock is still right twice a day. |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sun Feb 17, 2008 10:31 pm Post subject: |
|
|
Umm... not sure what you mean. I assume you're talking about this:
Code: | if ( (V1==2, and, V2==2, and, V3==2, and, V4==2),
or,
(V5==4, and, V6==4, and, V7==4, and, V8==4) )
then (endoftheworldasweknowit) |
I think the answer is no. "(V1==2, and, V2==2, and, V3==2, and, V4==2), or, (V5==4, and, V6==4, and, V7==4, and, V8==4)" is a single expression, and if branches depending on on the overall value. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|