Room as Main Menu - need help scripting - *SOLVED*

Started by rickious, Sun 26/10/2014 19:10:21

Previous topic - Next topic

rickious

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.


  • How do I make a hotspot click open the load game?
  • How do I make a hotspot click exit the game with usual confirmation dialog box?
  • How do I make a hotspot click open the options menu?
  • How do I rescript the 'exit' button on the regular GUI to exit to the main menu instead?

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

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.
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

Cassiebsg

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

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. :)
There are those who believe that life here began out there...

rickious

Thanks Cassiebsg, ill give it a go now :)
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

rickious

:~(

added this...
Code: ags

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
  object[0].Clickable = false;

on them, so they shouldn't be interfering.

any ideas
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

rickious

Adding that to my room code by the way.  am i missing something in the global script or something?
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

Cassiebsg

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. ;)
There are those who believe that life here began out there...

rickious

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.
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

Mandle

#7
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

function hExitButton_AnyClick()
{
  QuitGame(1);
}

function hLoadGameButton_AnyClick()
{
  show_restore_game_dialog();
}

NickyNyce

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
import function show_restore_game_dialog();

rickious

#9
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
  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
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.
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

SMF spam blocked by CleanTalk