AND operator?

For builders to discuss and ask building questions.
Post Reply
Nylo
Sword Grand Master
Sword Grand Master
Posts: 447
Joined: Tue Jul 26, 2011 7:15 pm
Location: Ohio, USA

AND operator?

Post by Nylo » Tue Apr 23, 2013 5:15 am

Do we have the && operator for IF checks or will I need to stack IF statements?

Edit: Example:

Code: Select all

if (quest(1,1,$n) == 0 && level($n) == 10)
endif

vs

if (quest(1,1,$n) == 0)
  if (level($n) == 10)
  endif
endif
Nylo, Fighter of Tempus
Anver, Transmuter of Garl
Malic, Cleric of Tyr
Luthir, Druid of Mielikki
Solaghar
Staff
Staff
Posts: 1283
Joined: Sun Nov 16, 2003 8:33 am
Location: Menzoberranzan

Re: AND operator?

Post by Solaghar » Tue Apr 23, 2013 8:35 am

You have to nest the if statements like the second example, as far as I know!
User avatar
Harroghty
Staff
Staff
Posts: 9695
Joined: Tue Jul 27, 2004 5:38 pm

Re: AND operator?

Post by Harroghty » Tue Apr 23, 2013 11:17 am

You can use and.

Code: Select all

if level($n) == 10
and quest(0, 1, $n) == 1
  say Yes
else
  say No
endif
The problem is that you cannot have both or and and in the same program. It is therefore easier usually to just use nested if checks, but and can simplify things sometimes.
"A man may die yet still endure if his work enters the greater work, for time is carried upon a current of forgotten deeds, and events of great moment are but the culmination of a single carefully placed thought." - Chime of Eons
Nylo
Sword Grand Master
Sword Grand Master
Posts: 447
Joined: Tue Jul 26, 2011 7:15 pm
Location: Ohio, USA

Re: AND operator?

Post by Nylo » Tue Apr 23, 2013 12:30 pm

As long as they're in different programs, can I use both? e.g. a greetprog with AND, then a giveprog with OR? More than once per prog, or only once?
Nylo, Fighter of Tempus
Anver, Transmuter of Garl
Malic, Cleric of Tyr
Luthir, Druid of Mielikki
User avatar
Harroghty
Staff
Staff
Posts: 9695
Joined: Tue Jul 27, 2004 5:38 pm

Re: AND operator?

Post by Harroghty » Tue Apr 23, 2013 1:05 pm

Yes, they only cannot be used together in the same program. They can be used as much as you want within those programs, just remember that there is a length limit on programs (which you likely will not reach - it's big).
"A man may die yet still endure if his work enters the greater work, for time is carried upon a current of forgotten deeds, and events of great moment are but the culmination of a single carefully placed thought." - Chime of Eons
Nylo
Sword Grand Master
Sword Grand Master
Posts: 447
Joined: Tue Jul 26, 2011 7:15 pm
Location: Ohio, USA

Re: AND operator?

Post by Nylo » Tue Apr 23, 2013 1:08 pm

Alright, I think that should do it, then. Thanks!
Nylo, Fighter of Tempus
Anver, Transmuter of Garl
Malic, Cleric of Tyr
Luthir, Druid of Mielikki
Mask
Staff
Staff
Posts: 2649
Joined: Tue Jul 15, 2003 9:21 pm

Re: AND operator?

Post by Mask » Wed Apr 24, 2013 8:16 pm

You can use them in the same prog, just not in the same if statement. For example, if you use if a and b or c and g or j, since we don't have parentheses to denote precedence, the game doesn't know what you mean.
Post Reply