Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: mport2004 on Mon 10/10/2005 23:43:17

Title: Script not working
Post by: mport2004 on Mon 10/10/2005 23:43:17
In my game i have a gard tower that shoots your guys when they get near it.
I have this script for when you attack it.


if (GetGlobalInt(14) == 1) {
character[BB].Animate(4, 1, 0, eBlock, eForwards);
int ran=Random(3);
if (ran==0) character[GT].Animate(1, 1, 0, eBlock, eForwards);SetGlobalInt(2,1);
if (ran==1) character[GT].Say("1");
if (ran==2) character[GT].Say("2");
if (ran==3) character[GT].Say("3");
}

when my guys attack it even if it dosent get a 0 for the random # it still uses SetGlobalInt(2,1);Ã,  ???
Title: Re: Script not working
Post by: strazer on Tue 11/10/2005 00:01:59
Quote from: mport2004 on Mon 10/10/2005 23:43:17
if (ran==0) character[GT].Animate(1, 1, 0, eBlock, eForwards);SetGlobalInt(2,1);

You have to enclose multiple commands within brackets, otherwise the conditional only works on the first command. Your code is the same as

if (ran==0) character[GT].Animate(1, 1, 0, eBlock, eForwards);
SetGlobalInt(2,1);


Try this instead:


if (ran==0) {
  character[GT].Animate(1, 1, 0, eBlock, eForwards);
  SetGlobalInt(2,1);
}
Title: Re: Script not working
Post by: mport2004 on Tue 11/10/2005 00:17:18
It worked thx
Title: Re: Script not working
Post by: monkey0506 on Tue 11/10/2005 02:00:02
And just to clarify, you can use cGt in place of character[GT], in case you didn't know. ;)