Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: EnterTheStory (aka tolworthy) on Mon 31/03/2008 15:28:39

Title: maximum number of && and || in one statement?
Post by: EnterTheStory (aka tolworthy) on Mon 31/03/2008 15:28:39
If there a maximum number of && and || in an if statement? And what about using brackets? For example, if I was to write this, would it work? I'm not planning to (yet!) but I like to know how far I can push the envelope...

if((((A==1)&&(B==2))||((C!=3)&&(D!=-4))||E)||F||G||(H>I)||(J<=K)||((M&&N&&O&&!P)||(Q+1==R))||(S==null)||(bla(T))||U||V||(W&&X&&!Z)){Display("whew!");}
Title: Re: maximum number of && and || in one statement?
Post by: Radiant on Mon 31/03/2008 18:39:21
Not that I have encountered. That means, for all practical purposes there probably isn't.

But, to avoid making things illegible for yourself, I'd recommend against writing things like this.
Title: Re: maximum number of && and || in one statement?
Post by: EnterTheStory (aka tolworthy) on Mon 31/03/2008 19:17:38
Thanks. My reason for asking is I have over 600 items that can be clicked on, and I'm writing the dialogue for each. Multiply those 600 by up to 200 different characters, and the task becomes a little crazy! So I'm grouping similar objects together, e.g.

if((what="house")||(what="big house")||(what="small house")||(what="home")||(what="apartment")||(what="hovel")||(what="yellow house")||(what="building with two bedrooms")||(what="cosy cottage")||etc., etc., etc.)
character[who].Say("What a nice house.");

From what you say it should not matter if my lists get a little but long. :)
Thanks again.
Title: Re: maximum number of && and || in one statement?
Post by: SSH on Mon 31/03/2008 20:01:18

String possibilities="housebig housesmall househomeapartmenthovelyellow housebuilding with two bedroomscosy cottage";

if (possibilities.Contains(what)) {
// do stuff
}

Title: Re: maximum number of && and || in one statement?
Post by: EnterTheStory (aka tolworthy) on Mon 31/03/2008 21:28:23
Contains, eh? Now there's an idea. Thanks.

I take it there's no performance hit with adding another long string? I don't know how AGS compares strings, but I have a vague recollection that checking character by character can be CPU intensive. Of course, I'm maybe thinking back to the days of the 286 here... :)
Title: Re: maximum number of && and || in one statement?
Post by: Khris on Wed 02/04/2008 11:29:19
A check like that wouldn't be performed every loop, would it?
So there shouldn't be any performance issue.