Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Construed on Tue 21/01/2014 00:54:58

Title: DoOnce region help
Post by: Construed on Tue 21/01/2014 00:54:58
I tried adding the display() function to Game.DoOnceOnly() and could not figure out how its supposed to be done.
Anyone know by chance?

Code (ags) Select

function room_Load()
{
//Guards
object[2].SetView(94, 0);
object[3].SetView(25, 0);
}

function region1_WalksOnto()
{
if (Game.DoOnceOnly("Be careful sir, Most do not return from the harsh desert ahead!")) {
}

//Display("Be careful sir, Most do not return from the harsh desert ahead!");

object[2].Animate(0, 5, eOnce, eNoBlock);
object[3].Animate(0, 5, eOnce, eNoBlock);

}


This is for two guards who guard a door and they move their spears aside when you walk upon the region.
Thanks a mill in advance!

-Jared
Title: Re: DoOnce region help
Post by: NickyNyce on Tue 21/01/2014 02:10:25
Here's an example of how I have used it. ReallySlug is the key word that AGS checks for, if it has not been used it will run the condition under it, otherwise if it has been used once already, it will run the else further below. Use any name you want, just make sure you never use the same one twice.

I'm no super scripter, but this should help.

Code (AGS) Select
function hControls_Interact()
{
  if(Game.DoOnceOnly("ReallySlug"))
  {
    cMoss.Walk(331, 303, eBlock, eWalkableAreas);
    cMoss.FaceLocation(331, 0, eBlock);
    cSlug.FaceLocation(1340, 303, eBlock);
    cSlug.Say("Really?      ");
  }
  else
  {
    cSlug.Say("I better leave it alone.");
  }
}


It's been a while since I played around with AGS and for some reason I'm having an issue placing this as code. (Fixed -Snarky)
Title: Re: DoOnce region help
Post by: Construed on Tue 21/01/2014 04:26:59
Thanks my friend, That does the trick!
God bless!

-Jared
Title: Re: DoOnce region help
Post by: Khris on Tue 21/01/2014 10:32:38
Why did you leave the { } block empty...? And why is this in Advanced...?
Title: Re: DoOnce region help
Post by: Snarky on Tue 21/01/2014 11:43:21
Good point. Moved.