Change Room GUI

Started by kafka, Mon 01/05/2006 14:32:04

Previous topic - Next topic

kafka

I want to make a GUI that changes rooms. I mean, when the character uses a hotspot, a custom GUI opens up and shows buttons. When you push a button, it takes you to another room. How do I do this? In the GUI tutorial it says, that the GUI tutorial is old and has to be updated. So how do I script GUIS and make this thing work? Thanks.

Ashen

#1
Out of curiosity, which GUI tutorial are you talking about? This bit of the BFAQ says that, but really isn't that much to do with what you want anyway.

Simply put:
Make your GUI in the editor (set the size and position, add the buttons, select graphics, etc - this bit hasn't really changed much).
Select a button. Notice that the first line of the floatng properties window now says 'Script Name'. Double click that, and give the button a script name.
Now double click the button. If necessary, click 'OK' to confirm the script function name.
You should now be in the Script Editor, at the Control function for your button. Add whatever code you want the button to run (e.g. player.ChangeRoom(42);).
Exit & save changes. The Button should now work - repeat this for all the buttons on the GUI (note that each button must have a unique name).

In the Hotspot interaction, use the GUI.Visible property to turn the GUI on. (You'll probably also want to use it in the Button Control functions, to turn it off before going to the new room.)
I know what you're thinking ... Don't think that.

kafka

#2
Oh... Thanks. Didn't know how to add my own scripts. Stupid me. It was THAT easy.  ;D

How do I make it invisible in the start? And how do I popup it?

Ashen

Since you posted before I could edit this in:

For future reference, you don't HAVE to accept the default Control function name, if you'd find another more meaningfull. This also means you can have several Buttons running the same function - if, for example you had multiple GUIs with Quit buttons on them, you could set them all to Quit_Click rather than repeating the same code for each of them.

And I already answered your second question:
Quote from: Ashen on Mon 01/05/2006 14:45:13
use the GUI.Visible property to turn the GUI on

Read that manual entry - GUI.Visible has taken the place of GUIOn/Off. If your GUI is called gChange:
Code: ags

gChange.Visible = true: // turns it on
gChange.Visible = false;// turns it off - put this in game_start to make it invisible at the start


NOTE: If the GUI is set to 'Popup Modal', it shouldn't be visible to start with anyway, it's only 'Normal' GUIs you'll have to turn off in game_start.
I know what you're thinking ... Don't think that.

kafka

Thanks! Works great!

SMF spam blocked by CleanTalk