Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: RetroJay on Wed 07/11/2007 22:51:33

Title: Scripting help required. Please!
Post by: RetroJay on Wed 07/11/2007 22:51:33
Hi everyone.
I have been doing very well with a project I started recently but have now hit a brick wall.
In my game I have a control panel that has a button on it to open a viewing screen. I set this as a HOTSPOT.
Interacting with it runs my small animation and the screen opens. GREAT!
Here is the prob. I now want to be able to interact with the same button again to close the screen. This is where it's going wrong!
I have been doing fairly well with scripting and have managed to get some tricky things sorted on my own.
However this prob has me scratching my head.
Please help me then I can surge ahead.........Hopefully!
Thanks.
Title: Re: Scripting help required. Please!
Post by: Khris on Wed 07/11/2007 23:46:42
I'm wondering what tricky things you did without ever using variables ;)

Although in this case, you probably won't even need one.
I guess the screen is an object and the small animation stops at the end of the loop to show the open screen, right?
Say the frame number of the open screen is 7:

//interact button
if (oScreen.Frame==0) {
  // open screen
}
else if (oScreen.Frame==7) {
  // close screen
}
Title: Re: Scripting help required. Please!
Post by: RetroJay on Thu 08/11/2007 03:09:10
VARIABLES!!!.......What the hell are those...... ;D
I did say that I am learning.
I have managed a few bits of scripting to get me out of tight spots by reading the tutorials and help files.
If that doesn't work then I find that Harsh language and someone to beat helps. ;)
Being sensible now. Thanks for your help, KhrisMUC, but it hasn't solved my prob.
It didn't work or I have done something wrong. I personaly would go with the latter.
All I have done is to create two hotspots on the control panel next to each other labled "OPEN SCREEN" and "CLOSE SCREEN" with a reason
as to why you should close the screen before continuing.
Yet again thankyou for your prompt reply.

P.S. sorry I didn't say that I'm learning. But infact I am learning......Something like that anyway!
Title: Re: Scripting help required. Please!
Post by: Khris on Thu 08/11/2007 03:51:51
So you've created a second button? Because in the first post you said you wanted to do it with just one.

What are you using to show the animation of the screen opening? You ARE using an object, right?

And please post your code so I can take a look at what you've tried.
Title: Re: Scripting help required. Please!
Post by: theatrx on Thu 08/11/2007 05:20:22
Khris is so good with the frame stuff.  He got me out of a horrible bind.
Title: Re: Scripting help required. Please!
Post by: RetroJay on Thu 08/11/2007 22:51:45
Hi.
Thankyou very much Khris.
Your code DID work, as I'm sure you already knew, It was my mistake.
This is how I Got it to work, with your help:

CODE:
    // script for Hotspot 2 (button): Interact hotspot
  object[3].SetView(4);
//interact button
if (oScreen.Frame==0) {
  // open screen
  object[3].Animate(0, 8);   
}
else if (oScreen.Frame==8) {
  // close screen
  object[3].Animate(0, 8, eOnce, eNoBlock, eBackwards);
}

It all now works perfectly.
yet again Thankyou very very much for your help.

P.S. The smiley cool face in the code is supposed to be 8 followed by a closed bracket.
Title: Re: Scripting help required. Please!
Post by: Khris on Fri 09/11/2007 03:39:51
You're welcome :)

To post code, you use the [ code] [ /code] or [ pre] [ /pre] tags (without the spaces).