Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Question about "or"

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
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!

PostPosted: Fri Feb 15, 2008 3:37 pm    Post subject: Question about "or" Reply with quote

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
View user's profile Send private message Send e-mail AIM Address
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Fri Feb 15, 2008 3:51 pm    Post subject: Re: Question about "or" Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Newbie_Power




Joined: 04 Sep 2006
Posts: 1762

PostPosted: Fri Feb 15, 2008 3:56 pm    Post subject: Re: Question about "or" Reply with quote

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
View user's profile Send private message
Gizmog1
Don't Lurk In The Bushes!




Joined: 05 Mar 2003
Posts: 2257
Location: Lurking In The Bushes!

PostPosted: Fri Feb 15, 2008 4:02 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail AIM Address
Rya.Reisender
Snippy




Joined: 18 Jan 2008
Posts: 821

PostPosted: Fri Feb 15, 2008 11:07 pm    Post subject: Reply with quote

That's a pretty good song.
Back to top
View user's profile Send private message MSN Messenger
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sat Feb 16, 2008 10:23 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Raekuul
Delicious!




Joined: 31 Mar 2004
Posts: 641
Location: Nowhere

PostPosted: Sun Feb 17, 2008 1:25 pm    Post subject: Reply with quote

So, those brax in JP's example are just like 'else's?
_________________
A broken clock is still right twice a day.
Back to top
View user's profile Send private message Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sun Feb 17, 2008 10:31 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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