Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: KristjanMan on Mon 01/05/2006 17:27:09

Title: 'If character view is' condition and 'If...
Post by: KristjanMan on Mon 01/05/2006 17:27:09
Ok I'm using AGS 2.71 and i want to know someting.
I want to check if character is in view 2 if it is then the character will say someting and if not say something else I understand how to make character say something so how do I check what view character is in i know it goes like this:
if (?) {
character[EGO].Say("text");
}
else {
character[EGO].Say("text");
}

Now what do I have to put where the question mark is?
Title: Re: If-s
Post by: scotch on Mon 01/05/2006 17:30:42
if (character[EGO].View==2) {
character[EGO].Say("text");
}
else {
character[EGO].Say("text");
}


Also be aware that using the character[] array is outdated, you can do it more concisely with the script-o-matic name displayed in the character editor, like
if (cEgo.View==2) {
cEgo.Say("text");
}
else {
cEgo.Say("text");
}
Title: Re: If-s
Post by: KristjanMan on Mon 01/05/2006 17:33:22
Thanks if I have more if problems I'll post it in this topic
Title: Re: 'If character view is' condition
Post by: Gilbert on Tue 02/05/2006 01:54:36
The character[] array is not outdated, it's very useful if you want to iterate on the character #, like for example setting stuff of multiple characters with a while loop.
However, if you're referring to a specific character then yes, cEgo is more preferred and more readible for current versions of AGS.
Title: Re: 'If character view is' condition and 'If...
Post by: KristjanMan on Sun 14/05/2006 16:59:46
I have another problem with 'if' how do I check that player has a inventory item?Please help those sneaky monsters (if-s) are very hard to me!
Title: Re: 'If character view is' condition and 'If...
Post by: Ashen on Sun 14/05/2006 17:11:23
Character.InventoryQuantity (http://www.adventuregamestudio.co.uk/manual/Character.InventoryQuantity.htm)

See also this post (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=25926.0) from not that long ago (amongst others) for an example of it in an if statement.
Title: Re: 'If character view is' condition and 'If...
Post by: KristjanMan on Sun 14/05/2006 17:19:36
Ok thanks it worked but how do I check if character is animating but not animating any animation but for example view 1 loop 1
Title: Re: 'If character view is' condition and 'If...
Post by: Ashen on Sun 14/05/2006 17:29:20
Read the manual  - these questions don't seem to be problems with ifs so much as just not knowing which functions/properties to use in them. Which you should do, once you've read the manual.

In this case, you'll need to use a few different ones - Character.View, Character.Loop and Character.Animating. e.g.:

if (cEgo.Animating && cEgo.View == 1 && cEgo.Loop == 1) {
  //Do stuff
}
Title: Re: 'If character view is' condition and 'If...
Post by: KristjanMan on Sun 14/05/2006 17:39:16
Thanks! I too dumb to use the manual  :-[