'If character view is' condition and 'If...

Started by KristjanMan, Mon 01/05/2006 17:27:09

Previous topic - Next topic

KristjanMan

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:
Code: ags
if (?) { 
character[EGO].Say("text");
}
else { 
character[EGO].Say("text"); 
}

Now what do I have to put where the question mark is?
- They are all from AGS coloringball

scotch

Code: ags
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
Code: ags
if (cEgo.View==2) { 
cEgo.Say("text");
}
else { 
cEgo.Say("text"); 
}

KristjanMan

Thanks if I have more if problems I'll post it in this topic
- They are all from AGS coloringball

Gilbert

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.

KristjanMan

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!
- They are all from AGS coloringball

Ashen

Character.InventoryQuantity

See also this post from not that long ago (amongst others) for an example of it in an if statement.
I know what you're thinking ... Don't think that.

KristjanMan

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
- They are all from AGS coloringball

Ashen

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.:
Code: ags

if (cEgo.Animating && cEgo.View == 1 && cEgo.Loop == 1) {
  //Do stuff
}
I know what you're thinking ... Don't think that.

KristjanMan

- They are all from AGS coloringball

SMF spam blocked by CleanTalk