Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Fri 16/07/2010 20:09:29

Title: SOLVED: Region and previous rooms with Has Inventory dillemas...
Post by: barefoot on Fri 16/07/2010 20:09:29
Hi

I think I'm having a mind blowing time at the moment... could someone look at this for me and correct .. I think you should see what i am trying to do..  will explain more if asked.

Any tips with script appreciated..


function region2_WalksOnto()
{
 if (player.PreviousRoom==61)
  object[2].Move(42, 497, 4, eBlock, eAnywhere);
 
 if (player.PreviousRoom==61)
  cindy_bones.Say("We've done that task!");

 else
 
 if (player.HasInventory (irod)) {
 }
 if (player.PreviousRoom==59)
 
Display("You enter into the next room cautiously");
   if (player.PreviousRoom==59)
  cprof_plum.ChangeRoom(60, 321, 355);
   if (player.PreviousRoom==59)
   cindy_bones.ChangeRoom(60, 331, 345);
}


cheers

-bareoot-

Title: Re: Region and previous rooms with Has Inventory dillemas...
Post by: Calin Leafshade on Fri 16/07/2010 20:26:22
ok you need to break this up.. youre having some problem with your curly brackets (sounds painful)

lets take a look


function region2_WalksOnto()
{

  if (player.PreviousRoom==61){

       object[2].Move(42, 497, 4, eBlock, eAnywhere);
       cindy_bones.Say("We've done that task!");

  }
  else if (player.HasInventory (irod) && player.PreviousRoom ==59) {

       Display("You enter into the next room cautiously");
       cprof_plum.ChangeRoom(60, 321, 355);
       cindy_bones.ChangeRoom(60, 331, 345);

  }
}


Now that is not exactly what your code did but I think thats what it *should* do.

Do you see how I've grouped unnecessary if statements together?

If you dont understand I can go into more detail.
Title: SOLVED: Re: Region and previous rooms with Has Inventory dillemas...
Post by: barefoot on Fri 16/07/2010 20:36:45
Calin... once again you've saved my bacon.. many thanks...

I see endless possibilities and try to put them into practice... sometimes of course i trip over.

Thank you for showing me about putting those conditions together. Once learnt, always remembered.. And I really must keeep an eye on my braces ;)

And yes, it works perfick...

Cheers

-barefoot-