We’ll start with the withdraw option. In this, you will be prompted to choose how much you want to withdraw from your account.
Let’s start with another Show Text command in which our bank teller again tells us how much we have in our account, then asks us how much we want to withdraw.
As you can see, we again use the \v[n] code to display the number stored into the Account variable.
After this Show Text command, we need an Input Number (page 1) command. With this command, you will need to choose what variable you want to store the number into. Let’s store the number into our Withdraw variable (Mine is variable ID #8. What’s yours?). We also need to choose how many digits we want to use to input our number. I’m going to use 7 digits for now, which will allow me to input a number as low as 0000000 or as high as 9999999.
Now is where things get tricky. We have to make sure that the player doesn’t take out more money than they have in their account. To do this, we need a Conditional Branch (page 1) command. When the window appears, select Variable and set the variable to your account. Then use the drop-down menu to change the mathematical symbol from the equal sign (=) to the greater than or equal to sign (≥). Next, change it from a constant to a variable and choose your Withdraw variable. Finally, before you click OK, check the Create Else Branch box.
Before moving forward with what happens when we do have enough, let’s program the Else branch. Let’s place a Show Text command inside the Else branch and have our bank teller say something along the lines of “I’m sorry, you don’t have that much in your account.” Follow this command with a Control Variables command. In this, set it to your Withdraw variable and leave the Operation at Set and leave the Operand to a Constant of 0. This will set it up so that if we were to attempt to withdraw again, the previous number we tried to input will no longer be there. Finally, place a Jump to Label (page 1) command and enter reset. This will jump the player back to where the label reset is placed – way back at the beginning.
Once those are in place, the Else branch is complete. Let’s move back to what happens when the If: Account ≥ Withdraw condition is met.
Inside our Conditional Branch, we need to remove the money from our account and add it to our current Gold. Let’s start by putting in a Control Variables command.
The Control Variable command will affect our Account variable. Set the variable at the top to your Account variable. Next, set the Operation to Sub (as in subtract). Finally, for the Operand, choose Variable and set it to your Withdraw variable.
Next, we need to use the Change Gold (page 1) command to change how much gold we are currently carrying in our inventory. Select this command and choose to Increase by a variable. Specifically, our Withdraw variable.
For the immersion of our game, let’s have our bank teller let us know how our account has changed. Let’s put in a Show Text command and have our bank teller say something along the lines of “Your account has been credited \v Gold. Thank you.” Remember, Variable #8 for me is my Withdraw variable.
After that, we then need to zero out our Withdraw variable. This will set it up so that the next time we go to withdraw money, it does not keep the previous amount of money we had chosen. To do this, put in another Control Variable command and choose your Withdraw variable. Keep the Operation at Set and leave the Operand at 0.
Finally, let’s place a Jump to Label command and write in reset. This will return the player back to the bank teller’s main menu.
With that, the Withdraw choice has been programmed! A copy of the code is below, followed by the rest of the tutorial.
Of course, we can’t withdraw money that we don’t have in the bank, so let’s move on to the Deposit choice so we can put some money in the bank!
*Please note that no tutorial may be copied or reproduced without the expressed written authorization of PODS Game Design. Any use of these tutorials to create a system(s) or function(s) in any game must be properly credited. Please contact PODS Game Design at email@example.com for further information.*