PDA

View Full Version : how to precache menu



malyczolg
9th April 2013, 14:41
hello i make new menu , how precache ?
i add :


init()
{
game["menu_ingame"] = "ingame";
game["menu_status"] = "status";
game["menu_team"] = "team_" + game["allies"] + game["axis"];
game["menu_weapon_allies"] = "weapon_" + game["allies"];
game["menu_weapon_axis"] = "weapon_" + game["axis"];

precacheMenu(game["menu_ingame"]);
precacheMenu(game["menu_team"]);
precacheMenu(game["menu_weapon_allies"]);
precacheMenu(game["menu_weapon_axis"]);
precacheMenu(game["menu_status"]);

IzNoGoD
9th April 2013, 15:28
If you cannot figure out how to precache a menu by looking at the code you posted yourself, I'd advise you to look for another hobby besides cod2 scripting.

kung foo man
9th April 2013, 15:30
what he means, is, that precacheMenu() is already precaching the menus

IzNoGoD
9th April 2013, 21:18
Which should be quite clear by the function name.
Let dissect that one for a bit, shall we?

precacheMenu() consists of 2 parts, namely:


precache
and


Menu
The goal of function names is to be descriptive.
Following said convention, this function should do something with a Menu, whereas the action might be closely related to the word precache.

As to return to your original question:


hello i make new menu , how precache ?
You obviously are trying to do something with menus, which might be fulfilled by the above function. As your question is on "how to precache a menu", it might be quite clear which function you need to use, not in the least because the code you quoted is indeed the stock cod2 code to precache the menus from a stock cod2 installation. The correct syntaxis is thus


precacheMenu(menuname_goes_here);


Now, to return to your question about exactly how to precache menus, this is quite simple. As you know, .menu files have a filename and a title (defined within the file). These two should match (although it might be allowed to use different filenames, which could work, but make your mod much harder to debug should something fail). By then, you should have a name for that .menu file, lets call it


typing_this_is_actually_quite_boring
So, by then you could recall the syntax for the precacheMenu function. To re-iterate:


precacheMenu(menuname_goes_here);


As you now know the menu-name, you can call the function as follows:


precacheMenu("typing_this_is_actually_quite_boring");

This should precache your menu.

I hope this answers your question, if not, feel free not to post about it.

Tally
10th April 2013, 16:28
if you cannot figure out how to precache a menu by looking at the code you posted yourself, i'd advise you to look for another hobby besides cod2 scripting.

^this^

code10