Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: steptoe on Sun 05/08/2012 19:33:26

Title: Replace 2 Ints with Bool
Post by: steptoe on Sun 05/08/2012 19:33:26
Hi

I'm looking at manual to find the best way of doing this:


EDIT: Surely must be:
Rep Exec
Code (AGS) Select

if(Enemy1a <= 0 && Enemy1b <= 0)
{
bool=true;
}


--------------------------



Int A (Enemy1a) plus Int B (Enemy1b) (or vise versa) = Bool false/true sort of thing.

I want to replace Enemy1a >= 1 && Enemy1b >= 1 with a bool=false and change if both Ints are met (Both Int=0) by Rep Exec to true.
Code (AGS) Select

{
if(cryan.ActiveInventory==igrenade && Enemy1a >= 1 && Enemy1b >= 1)
{
cblondie.FaceLocation(292, 206);
Grenades=(Grenades -1);
object[8].X =cblondie. x-0;
object[8].Y = cblondie.y- 0;
cblondie.ChangeView(10);
cblondie.Animate(0, 6, eOnce, eBlock);
object[8].Visible=true;
cblondie.ChangeView(7);

//PLUS MORE AS RANDOM INTS


Would someone please assist

cheers

Title: Re: Replace 2 Ints with Bool
Post by: Atelier on Sun 05/08/2012 20:06:08
Something like:

Code (AGS) Select

bool mybool;

function repeatedly_execute()
{
     if (!Enemy1a && !Enemy1b) mybool = true;
}

if (cryan.ActiveInventory == igrenade && mybool)


?
Title: Re: Replace 2 Ints with Bool
Post by: steptoe on Mon 06/08/2012 11:10:59
Hi

I have already gone with another sure-fire option.

cheers

Title: Re: Replace 2 Ints with Bool
Post by: Crimson Wizard on Mon 06/08/2012 11:34:46
A small hint.
Since the result of any condition is boolean value on its own, writing
Code (ags) Select

if (!Enemy1a && !Enemy1b) mybool = true;

is considered a bit redundant. Simplier way is
Code (ags) Select

mybool = !Enemy1a && !Enemy1b;
Title: Re: Replace 2 Ints with Bool
Post by: steptoe on Mon 06/08/2012 11:45:40
Cheers Crimson Wizard,

Just to confirm (in case we have cross wires):

Enemy1a && Enemy1b are Ints that both start at 3 and when both reach 0 a bool becomes true.

Although I have chosen another option knowing this way may help me for later on.

cheers

While I'm here, I may as well slip this one in:

Rep Exec:

Is it possible to display Mouse Walk graphic while executing this code before changing modes?

Code (AGS) Select
}
if (mouse.Mode==eModeWalkto)
{

cryan.SpeechView=14;
cryan.Say("I'm too busy reading this map to walk around!");
mouse.SelectNextMode();
}
}


cheers again