MenuMate Tutorial
This tutorial shows a basic example of menu creation with MenuMate. We will create a basic menu interface for a bank-type mod, which allows the player to deposit and withdraw money from a bank account. The menu created in this tutorial is included in the MenuMate download.
GoalsEdit
Our menu will consist of three dialogs:
- The main menu. Will show the player their account balance and allow them to choose between making a deposit or withdrawal.
- The deposit menu. Allows the player to enter an amount of gold to deposit, up to the amount they currently are carrying.
- The withdrawal menu. Allows the player to enter an amount of gold they wish to withdraw from their account, up to their current account balance.
ImplementationEdit
ScriptEdit
We still need a small script to support our menu XML. This script will display the menu and contain several variables used by the menu.
scn BankDemoScript int accountBalance ref playerRef int playerGold int minVar int temp int invert int displayStatus float fQuestDelayTime begin MenuMode if (displayStatus) mmUpdate endif end begin GameMode set fQuestDelayTime to 0.0001 if (displayStatus == 0) set playerRef to player set playerGold to player.GetItemCount Gold001 set minVar to 0 set temp to 0 set invert to 0 if (mmLoadMenu "demo.xml") set displayStatus to 1 else PrintC "menu failed to load" StopQuest BankDemo endif elseif (mmGetStatus == 1) set displayStatus to 0 StopQuest BankDemo endif end
XMLEdit
The XML of our desired menu is as follows:
<?xml version="1.0" ?> <menu> <start name="main"/> <dialog name="deposit"/> <dialog name="withdraw"/> <dialog name="buttondemo"/> </menu> <main> <text format="Greetings %n!%rYour balance is %.0f gold, what do you wish to do?"> <param name="playerRef"/> <param name="accountBalance"/> </text> <linkbutton target="deposit"> <text format="Make a deposit"/> </linkbutton> <linkbutton target="withdraw"> <text format="Withdraw money"/> </linkbutton> <exitbutton> <text format="Nothing"/> </exitbutton> </main> <!-- This dialog inverts its counterbuttons via a togglebutton + toggle variable --> <deposit> <text format="Deposit Amount: %.0f%rYou have %.0f gold"> <param name="temp"/> <param name="playerGold"/> </text> <togglebutton targetvar="invert" truetext="subtracting" falsetext="adding"> <text format="Toggle Add/Subtract%r(currently [STATE])"/> </togglebutton> <counterbutton targetvar="temp" amount="1" invertvar="invert" maxvar="playerGold" minvar="minVar"> <text format="[STATE]"/> </counterbutton> <counterbutton targetvar="temp" amount="10" invertvar="invert" maxvar="playerGold" minvar="minVar"> <text format="[STATE]"/> </counterbutton> <counterbutton targetvar="temp" amount="100" invertvar="invert" maxvar="playerGold" minvar="minVar"> <text format="[STATE]"/> </counterbutton> <counterbutton targetvar="temp" amount="1000" invertvar="invert" maxvar="playerGold" minvar="minVar"> <text format="[STATE]"/> </counterbutton> <exitbutton> <text format="Finish"/> <script> set BankDemo.accountBalance to BankDemo.accountBalance + BankDemo.temp player.RemoveItem 0000000F BankDemo.temp MessageBox "Your new balance is %.0f gold" BankDemo.accountBalance </script> </exitbutton> <exitbutton> <text format="Cancel"/> </exitbutton> </deposit> <!-- This dialog makes use of the toggle key(s) to invert its counters --> <withdraw> <text format="Withdraw Amount: %.0f%rYour balance is %.0f gold%r%rHold one of these keys to decrease the amount: [INVERTKEYS]"> <param name="temp"/> <param name="accountBalance"/> </text> <counterbutton targetvar="temp" amount="1" maxvar="accountBalance" minvar="minVar" usekeyinvert="1"> <text format="[STATE]"/> </counterbutton> <counterbutton targetvar="temp" amount="10" maxvar="accountBalance" minvar="minVar" usekeyinvert="1"> <text format="[STATE]"/> </counterbutton> <counterbutton targetvar="temp" amount="100" maxvar="accountBalance" minvar="minVar" usekeyinvert="1"> <text format="[STATE]"/> </counterbutton> <counterbutton targetvar="temp" amount="1000" maxvar="accountBalance" minvar="minVar" usekeyinvert="1"> <text format="[STATE]"/> </counterbutton> <exitbutton> <text format="Finish"/> <script> set BankDemo.accountBalance to BankDemo.accountBalance - BankDemo.temp player.AddItem 0000000F BankDemo.temp MessageBox "Your new balance is %.0f gold" BankDemo.accountBalance </script> </exitbutton> <exitbutton> <text format="Cancel"/> </exitbutton> </withdraw>