Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: rickious on Sun 26/10/2014 19:10:21

Title: Room as Main Menu - need help scripting - *SOLVED*
Post by: rickious on Sun 26/10/2014 19:10:21
Apologies if this has been asked and answered, but been researching and testing for several hours and have not come up with an answer.

I opted to use a room as my main menu.  I have hotspots on menu text and am using objects for rollover effects, and I have hidden the icon menu from the top.  But as far as button clicking, so far I have only managed to get the "New Game" button working.  So my questions if you can please help.


I know thats a lot of questions, but i have exhausted my trial and error time for now.  I need to crack on with some more in-game content and hope someone can help.


Im not sure how many GUI types there are so here is some info. Im using the GUI style that drops down from the top. And the load/restore game GUI is called called 'gRestoreGame' in the GUI list.

Here is some code from my global script, maybe it helps?....
Code (ags) Select

function btnIconSave2_OnClick(GUIControl *control, MouseButton button)
{
  show_restore_game_dialog();
}


ive tried all sorts of things, any click, mouse click, mousebutton. Some of the things i tried didnt show any errors but nothing happened. Im sure several of you know exactly what to do and although Id have loved to figure it out myself but after this long struggling id think i need to ask the experts.

all help appreciated.
Title: Re: Room as Main Menu - need help scripting
Post by: Cassiebsg on Sun 26/10/2014 19:45:15
First off, you'll probably want to use the anyclick event, unless you want to make some "fancy" stuff with the way to click on the buttons.

Here's a little snip:
Code (ags) Select

function hQuit_AnyClick()
{
  QuitGame(1);
}

function hNew_AnyClick()
{
  player.ChangeRoom(1); 
}

function hLoad_AnyClick()
{
  gRestoreGame.Visible=true;
}


function hPanel_AnyClick()
{
gPanel.Visible=true;
}


If you want your own custom quit confirmation GUI, you need to create the GUI, add buttons, and on the quit button then use the command
  QuitGame(0); instead of the 1 (the 0 quits imediatly, but since you already confirmed with your own GUI then you don't want another confirmation screen).

Hope this helps a bit. :)
Title: Re: Room as Main Menu - need help scripting
Post by: rickious on Sun 26/10/2014 20:07:38
Thanks Cassiebsg, ill give it a go now :)
Title: Re: Room as Main Menu - need help scripting
Post by: rickious on Sun 26/10/2014 20:15:32
:~(

added this...
Code (ags) Select

function hExitButton_AnyClick()
{
  QuitGame(1);
}

function hLoadGameButton_AnyClick()
{
  gRestoreGame.Visible=true;
}


no errors, but nothing happens when i click hLoadGameButton or hExitButton hotspots.

I have objects appearing for my rollovers but I have used...
Code (ags) Select
  object[0].Clickable = false;
on them, so they shouldn't be interfering.

any ideas
Title: Re: Room as Main Menu - need help scripting
Post by: rickious on Sun 26/10/2014 20:27:11
Adding that to my room code by the way.  am i missing something in the global script or something?
Title: Re: Room as Main Menu - need help scripting
Post by: Cassiebsg on Sun 26/10/2014 20:28:00
I'm not the right one to debug your problem. But you could try and disable the rolovers, or anything that might be interfering. just add a // in front of the line and see if it helps.
Alternatively, create a new room, add a few hotspots and add the code, just to eliminate any other possible interference from other code.

And I'm assuming you did remember to link the code with the room's events page.

PS - Don't double post, edit your previous post instead. ;)
Title: Re: Room as Main Menu - need help scripting
Post by: rickious on Sun 26/10/2014 20:58:23
Hahahah, you got it in one, for got to add the any click on events.

So, next problem. When I go to restore game from my main menu no save games appear in the list. Any ideas?

Apologies for the triple post earlier.
Title: Re: Room as Main Menu - need help scripting
Post by: Mandle on Mon 27/10/2014 00:11:18
I believe that instead of making the SaveGame/RestoreGame GUI visible you actually need to do these to make the GUI work properly:

show_save_game_dialog();
show_restore_game_dialog();

Try using these instead of .Visible.

For example:

Code (ags) Select

function hExitButton_AnyClick()
{
  QuitGame(1);
}

function hLoadGameButton_AnyClick()
{
  show_restore_game_dialog();
}
Title: Re: Room as Main Menu - need help scripting
Post by: NickyNyce on Mon 27/10/2014 03:53:50
I didn't read this entire thread, but if things don't work for you with what Mandle provided, add this to the top of your room script..

Code (ags) Select
import function show_restore_game_dialog();
Title: Re: Room as Main Menu - need help scripting - *SOLVED*
Post by: rickious on Mon 27/10/2014 08:24:40
Mandle
it gives the following error
QuoteFailed to save room room301.crm; details below
room301.asc(19): Error (line 19): Undefined token 'show_save_game_dialog'
whenever i add...
Code (ags) Select
  show_save_game_dialog();

NickyNyce
I get no errors with this, but still no save games.

If I reactivate the icon bar, the load and save from that still work fine, if i save a game within the main menu from the icon bar even that one doesnt show with the menu button version of the restore game.

Theres some kind of fetch or load or retrieve the save games missing?  Is there something we need to tie into the global script where the GUI button version gets its load game menu from?

Or shall we give in and just make a new invisible GUI button instead of that hotspot and do it from that? IF we do it that way, can i still activate the rollover object in the same way as my 'Exit' and 'New Game' hotspot buttons do?

If the new GUI button is the best way to go, I could do with help on how to add that too (roll)

*EDIT*
Mandle and NickyNyce
The following combination of your scripts and my existing worked...
Code (ags) Select
import function show_restore_game_dialog();

function hLoadGameButton_AnyClick()
{
  gRestoreGame.Visible=true;
  show_restore_game_dialog();
}


Thanks all three of you for helping. AGS has an excellent, genuinely friendly community.