Author Topic: Replace 2 Ints with Bool  (Read 243 times)  Share 

Replace 2 Ints with Bool
« on: 05 Aug 2012, 19:33 »
Hi

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


EDIT: Surely must be:
Rep Exec
Code: Adventure Game Studio
  1. if(Enemy1a <= 0 && Enemy1b <= 0)
  2. {
  3. bool=true;
  4. }
  5.  
  6.  
  7. --------------------------
  8.  
  9.  

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: Adventure Game Studio
  1. {
  2. if(cryan.ActiveInventory==igrenade && Enemy1a >= 1 && Enemy1b >= 1)
  3. {
  4.  cblondie.FaceLocation(292, 206);
  5.  Grenades=(Grenades -1);
  6.  object[8].X =cblondie. x-0;
  7.  object[8].Y = cblondie.y- 0;
  8.  cblondie.ChangeView(10);
  9.  cblondie.Animate(0, 6, eOnce, eBlock);
  10.  object[8].Visible=true;
  11.  cblondie.ChangeView(7);
  12.  
  13.  //PLUS MORE AS RANDOM INTS
  14.  

Would someone please assist

cheers

« Last Edit: 05 Aug 2012, 20:06 by steptoe »
I am not dead, I am only sleeping ;)

Re: Replace 2 Ints with Bool
« Reply #1 on: 05 Aug 2012, 20:06 »
Something like:

Code: Adventure Game Studio
  1. bool mybool;
  2.  
  3. function repeatedly_execute()
  4. {
  5.      if (!Enemy1a && !Enemy1b) mybool = true;
  6. }
  7.  
  8. if (cryan.ActiveInventory == igrenade && mybool)

?
« Last Edit: 05 Aug 2012, 20:15 by Atelier »

Re: Replace 2 Ints with Bool
« Reply #2 on: 06 Aug 2012, 11:10 »
Hi

I have already gone with another sure-fire option.

cheers

I am not dead, I am only sleeping ;)

Crimson Wizard

  • AGS Project Admins
  • not et suppotreD
    • I can help with translating
    •  
Re: Replace 2 Ints with Bool
« Reply #3 on: 06 Aug 2012, 11:34 »
A small hint.
Since the result of any condition is boolean value on its own, writing
Code: Adventure Game Studio
  1. if (!Enemy1a && !Enemy1b) mybool = true;
  2.  
is considered a bit redundant. Simplier way is
Code: Adventure Game Studio
  1. mybool = !Enemy1a && !Enemy1b;
  2.  

Re: Replace 2 Ints with Bool
« Reply #4 on: 06 Aug 2012, 11:45 »
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: Adventure Game Studio
  1. }
  2.  if (mouse.Mode==eModeWalkto)
  3.  {
  4.  
  5.  cryan.SpeechView=14;
  6.  cryan.Say("I'm too busy reading this map to walk around!");
  7.  mouse.SelectNextMode();
  8.  }
  9.  }
  10.  

cheers again



I am not dead, I am only sleeping ;)