The Dink Network

Reply to Re: Levelup

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
October 16th 2007, 06:47 AM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
Hahahaha, not true. The menu parts of a multi-layered level-up menu (save, warp home, choose stats), or a multi-layered shop menu (buy, sell leave) are just as easy. As long as you properly add return;, a multi-layered menu is just as easy as a single layer of menu. As far as I know, the most common mistakes happen because &result gets overwritten:

void talk( void )
{

//In these examples, I'm cheap. There's no title, nothing fancy, just menu code.

choice_start();
"Choice 1"
"Choice 2"
choice_end();

if (&result == 1)
{

choice_start();
"Submenu 1, choice 1"
"Submenu 1, choice 2"
choice_end();

if (&result == 1)
{
//Do something
//Accidentally forget return; It goes unnoticed, as nothing weird happens.
}

if (&result == 2)
{
//Do something else
//Accidentally forget return; Since &result equals 2, the submenu 2 code will be executed, and you'll ask on the board wtd is going wrong.
}

}

if (&result == 2)
{
choice_start();
"Submenu 2, choice 1"
"Submenu 2, choice 2"
choice_end();

if (&result == 1)
{
//Do stuff
}

if (&result == 2)
{
//Do other stuff
}

}

}

Note that not only choice menus affect the value of &result. The wait_for_button() function also uses it. So, if you use wait_for_button() inside menu code, strange things may happen as well.

EDIT: I was typoing all over the place