Tutorials:Bank Tutorial

From Charas Project

(Difference between revisions)
(Updated with Code Template)
Line 8: Line 8:
We start by making an event that will be the actual bank system.  Make it ''Same Level as Hero'' and give it the graphic of a bankteller.  On the first page, we let the player decide whether they want to start an account.  This is simple enough.  Place a 'Show Message' command followed by a 'Show Choice' command to get this done.  What we get is something like this.
We start by making an event that will be the actual bank system.  Make it ''Same Level as Hero'' and give it the graphic of a bankteller.  On the first page, we let the player decide whether they want to start an account.  This is simple enough.  Place a 'Show Message' command followed by a 'Show Choice' command to get this done.  What we get is something like this.
-
<table border='0' align='center' width='90%' cellpadding='3' cellspacing='1' style="background-color:#000066;"><tr><td style='BORDER: #000000 1px solid; BACKGROUND-COLOR: #000099; color:#FFFFFF; font-family:Verdana; font-size:8pt;'>
+
{{code|code=<> Show Message: Welcome to the bank.  Would you like to start an account?<br />
-
<> Show Message: Welcome to the bank.  Would you like to start an account?<br />
+
<> Show Choices: Yes/No<br />
<> Show Choices: Yes/No<br />
: [Yes] Handler<br />
: [Yes] Handler<br />
-
<> Change Switch: [0001:Bank Account] - ON<br />
+
::<> Change Switch: [0001:Bank Account] - ON<br />
-
<> Show Message: Your account has been made<br />
+
::<> Show Message: Your account has been made<br />
-
: [No] Handler<br />
+
: [No] Handler<br />  
-
<> Show Message:  Very well, good day to you.
+
::<> Show Message:  Very well, good day to you.}}
-
</td></tr></table>
+
You can add to this later, but for now, it fits our purposes.  Remember that along with the following code, this should be included in ''every'' bank event.  The player could decide to start an account at any given time.
You can add to this later, but for now, it fits our purposes.  Remember that along with the following code, this should be included in ''every'' bank event.  The player could decide to start an account at any given time.
Line 22: Line 20:
Now we need the player to be able to withdraw and deposit their money.  For this we will need a total of 3 variables.  We'll call them
Now we need the player to be able to withdraw and deposit their money.  For this we will need a total of 3 variables.  We'll call them
-
<table border='0' align='center' width='90%' cellpadding='3' cellspacing='1' style="background-color:#000066;"><tr><td style='BORDER: #000000 1px solid; BACKGROUND-COLOR: #000099; color:#FFFFFF; font-family:Verdana; font-size:8pt;'>
+
{{code|code=Variable [0001: Current Money]<br />
-
Variable [0001: Current Money]<br />
+
Variable [0002: Bank Money]<br />
Variable [0002: Bank Money]<br />
-
Variable [0003: Bank Input]<br />
+
Variable [0003: Bank Input]}}
-
</td></tr></table>
+
Current Money will store the amount of money that the player currently has.  Bank Money will be the running total of money stored in the bank system.  And Bank Input will be what we use for the player to decide how much money to withdraw or deposit.
Current Money will store the amount of money that the player currently has.  Bank Money will be the running total of money stored in the bank system.  And Bank Input will be what we use for the player to decide how much money to withdraw or deposit.
Line 32: Line 28:
Now, lets make the actual bank system: the part that allows the player to withdraw and deposit their money at will.  Make a new page in the event, giving it the prerequisite of Switch[0001:Bank Account] - ON.  We start with a choice of withdrawing, depositing, or doing nothing.  A good thing to do is show the player how much money they currently have by using '\\$'.  We also show the amount of money in the bank by using '\\v[2]' to show the current value of the second variable: Bank Money.
Now, lets make the actual bank system: the part that allows the player to withdraw and deposit their money at will.  Make a new page in the event, giving it the prerequisite of Switch[0001:Bank Account] - ON.  We start with a choice of withdrawing, depositing, or doing nothing.  A good thing to do is show the player how much money they currently have by using '\\$'.  We also show the amount of money in the bank by using '\\v[2]' to show the current value of the second variable: Bank Money.
-
<table border='0' align='center' width='90%' cellpadding='3' cellspacing='1' style="background-color:#000066;"><tr><td style='BORDER: #000000 1px solid; BACKGROUND-COLOR: #000099; color:#FFFFFF; font-family:Verdana; font-size:8pt;'>
+
{{code|code=<> Show Message: Welcome to the bank.  What would you like to do?<br />
-
<> Show Message: Welcome to the bank.  What would you like to do?<br />
+
<> Show Message: \\$Your account currently has \\v[1] gold in it.<br />
<> Show Message: \\$Your account currently has \\v[1] gold in it.<br />
<> Show Choices: Withdraw/Deposit/Nothing<br />
<> Show Choices: Withdraw/Deposit/Nothing<br />
Line 41: Line 36:
...
...
: [Nothing] Handler<br />
: [Nothing] Handler<br />
-
<> Show Message:  Very well, good day to you.
+
<> Show Message:  Very well, good day to you.}}
-
</td></tr></table>
+
Let's begin with what happens upon choosing Withdraw.  First, show a message asking how much to withdraw, along with showing the player's current money and bank money.  Then we use a a'Input Number' command so the player can choose the amount.
Let's begin with what happens upon choosing Withdraw.  First, show a message asking how much to withdraw, along with showing the player's current money and bank money.  Then we use a a'Input Number' command so the player can choose the amount.
-
<table border='0' align='center' width='90%' cellpadding='3' cellspacing='1' style="background-color:#000066;"><tr><td style='BORDER: #000000 1px solid; BACKGROUND-COLOR: #000099; color:#FFFFFF; font-family:Verdana; font-size:8pt;'>
+
{{code|code=<> Show Message: \\$You have \\v[2] gold in the bank.  How much do you wish to withdraw?<br />
-
<> Show Message: \\$You have \\v[2] gold in the bank.  How much do you wish to withdraw?<br />
+
<> Input Number: 6 digits [0003: Bank Input]}}
-
<> Input Number: 6 digits [0003: Bank Input]
+
-
</td></tr></table>
+
Next, we have to make sure the player isn't withdrawing more money than they have in the bank.  We do this with a simple conditional fork.
Next, we have to make sure the player isn't withdrawing more money than they have in the bank.  We do this with a simple conditional fork.
-
<table border='0' align='center' width='90%' cellpadding='3' cellspacing='1' style="background-color:#000066;"><tr><td style='BORDER: #000000 1px solid; BACKGROUND-COLOR: #000099; color:#FFFFFF; font-family:Verdana; font-size:8pt;'>
+
{{code|code=<>Fork Option: Var[0003: Bank Input] equal to or less than Var[0002: Bank Money]<br />
-
<>Fork Option: Var[0003: Bank Input] equal to or less than Var[0002: Bank Money]<br />
+
...<br />
-
...
+
ELSE case<br />
-
: ELSE case<br />
+
:<> Show Message: Sorry, you don't have that much to withdraw.}}
-
<> Show Message: Sorry, you don't have that much to withdraw.
+
-
</td></tr></table>
+
If all is fine, then we subtract Bank Input from Bank Money and add Bank Input to the player's money.
If all is fine, then we subtract Bank Input from Bank Money and add Bank Input to the player's money.
-
<table border='0' align='center' width='90%' cellpadding='3' cellspacing='1' style="background-color:#000066;"><tr><td style='BORDER: #000000 1px solid; BACKGROUND-COLOR: #000099; color:#FFFFFF; font-family:Verdana; font-size:8pt;'>
+
{{code|code=<> Change Variable: [0002: Bank Money] minus [0003: Bank Input] value<br />
-
<> Change Variable: [0002: Bank Money] minus [0003: Bank Input] value<br />
+
<> Change Money: Increase by [0003: Bank Input] value}}
-
<> Change Money: Increase by [0003: Bank Input] value
+
-
</td></tr></table>
+
So all together, withdrawing will look like this.
So all together, withdrawing will look like this.
-
<table border='0' align='center' width='90%' cellpadding='3' cellspacing='1' style="background-color:#000066;"><tr><td style='BORDER: #000000 1px solid; BACKGROUND-COLOR: #000099; color:#FFFFFF; font-family:Verdana; font-size:8pt;'>
+
{{code|code=<> Show Message: \\$You have \\v[2] gold in the bank.  How much do you wish to withdraw?<br />
-
<> Show Message: \\$You have \\v[2] gold in the bank.  How much do you wish to withdraw?<br />
+
<> Input Number: 6 digits [0003: Bank Input]<br />
<> Input Number: 6 digits [0003: Bank Input]<br />
<>Fork Option: Var[0003: Bank Input] equal to or less than Var[0002: Bank Money]<br />
<>Fork Option: Var[0003: Bank Input] equal to or less than Var[0002: Bank Money]<br />
:<> Change Variable: [0002: Bank Money] minus [0003: Bank Input] value<br />
:<> Change Variable: [0002: Bank Money] minus [0003: Bank Input] value<br />
:<> Change Money: Increase by [0003: Bank Input] value<br />
:<> Change Money: Increase by [0003: Bank Input] value<br />
-
: ELSE case<br />
+
ELSE case<br />
-
<> Show Message: Sorry, you don't have that much to withdraw.
+
:<> Show Message: Sorry, you don't have that much to withdraw.}}
-
</td></tr></table>
+
Depositing is very similar.  The only differences are that you have to assign the player's money to a variable, and check that the input is lower than that.  And of course how it affects the player's money.
Depositing is very similar.  The only differences are that you have to assign the player's money to a variable, and check that the input is lower than that.  And of course how it affects the player's money.
-
<table border='0' align='center' width='90%' cellpadding='3' cellspacing='1' style="background-color:#000066;"><tr><td style='BORDER: #000000 1px solid; BACKGROUND-COLOR: #000099; color:#FFFFFF; font-family:Verdana; font-size:8pt;'>
+
{{code|code=<> Show Message: \\$You have \\v[2] gold in the bank.  How much do you wish to deposit?<br />
-
<> Show Message: \\$You have \\v[2] gold in the bank.  How much do you wish to deposit?<br />
+
<> Input Number: 6 digits [0003: Bank Input]<br />
<> Input Number: 6 digits [0003: Bank Input]<br />
'''<> Change Variable [0001: Current Money] set Money value'''<br />
'''<> Change Variable [0001: Current Money] set Money value'''<br />
Line 88: Line 73:
:<> Change Variable: [0002: Bank Money] '''add''' [0003: Bank Input] value<br />
:<> Change Variable: [0002: Bank Money] '''add''' [0003: Bank Input] value<br />
:<> Change Money: '''Decrease''' by [0003: Bank Input] value<br />
:<> Change Money: '''Decrease''' by [0003: Bank Input] value<br />
-
: ELSE case<br />
+
ELSE case<br />
-
<> Show Message: Sorry, you don't have that much to deposit.
+
:<> Show Message: Sorry, you don't have that much to deposit.}}
-
</td></tr></table>
+
All together...
All together...
-
<table border='0' align='center' width='90%' cellpadding='3' cellspacing='1' style="background-color:#000066;"><tr><td style='BORDER: #000000 1px solid; BACKGROUND-COLOR: #000099; color:#FFFFFF; font-family:Verdana; font-size:8pt;'>
+
{{code|code=<> Show Message: Welcome to the bank.  What would you like to do?<br />
-
<> Show Message: Welcome to the bank.  What would you like to do?<br />
+
<> Show Message: \\$Your account currently has \\v[1] gold in it.<br />
<> Show Message: \\$Your account currently has \\v[1] gold in it.<br />
<> Show Choices: Withdraw/Deposit/Nothing<br />
<> Show Choices: Withdraw/Deposit/Nothing<br />
: [Withdraw] Handler<br />
: [Withdraw] Handler<br />
-
<> Show Message: \\$You have \\v[2] gold in the bank.  How much do you wish to withdraw?<br />
+
::<> Show Message: \\$You have \\v[2] gold in the bank.  How much do you wish to withdraw?<br />
-
<> Input Number: 6 digits [0003: Bank Input]<br />
+
::<> Input Number: 6 digits [0003: Bank Input]<br />
-
<>Fork Option: Var[0003: Bank Input] equal to or less than Var[0002: Bank Money]<br />
+
::<>Fork Option: Var[0003: Bank Input] equal to or less than Var[0002: Bank Money]<br />
-
:<> Change Variable: [0002: Bank Money] minus [0003: Bank Input] value<br />
+
:::<> Change Variable: [0002: Bank Money] minus [0003: Bank Input] value<br />
-
:<> Change Money: Increase by [0003: Bank Input] value<br />
+
:::<> Change Money: Increase by [0003: Bank Input] value<br />
-
: ELSE case<br />
+
::ELSE case<br />
-
<> Show Message: Sorry, you don't have that much to withdraw.<br />
+
:::<> Show Message: Sorry, you don't have that much to withdraw.<br />
: [Deposit] Handler<br />
: [Deposit] Handler<br />
-
<> Show Message: \\$You have \\v[2] gold in the bank.  How much do you wish to deposit?<br />
+
::<> Show Message: \\$You have \\v[2] gold in the bank.  How much do you wish to deposit?<br />
-
<> Input Number: 6 digits [0003: Bank Input]<br />
+
::<> Input Number: 6 digits [0003: Bank Input]<br />
-
<> Change Variable [0001: Current Money] set Money value<br />
+
::<> Change Variable [0001: Current Money] set Money value<br />
-
<>Fork Option: Var[0003: Bank Input] equal to or less than Var[0001: Current Money]<br />
+
::<>Fork Option: Var[0003: Bank Input] equal to or less than Var[0001: Current Money]<br />
-
:<> Change Variable: [0002: Bank Money] add [0003: Bank Input] value<br />
+
:::<> Change Variable: [0002: Bank Money] add [0003: Bank Input] value<br />
-
:<> Change Money: Decrease by [0003: Bank Input] value<br />
+
:::<> Change Money: Decrease by [0003: Bank Input] value<br />
-
: ELSE case<br />
+
::ELSE case<br />
-
<> Show Message: Sorry, you don't have that much to deposit.<br />
+
:::<> Show Message: Sorry, you don't have that much to deposit.<br />
: [Nothing] Handler<br />
: [Nothing] Handler<br />
-
<> Show Message:  Very well, good day to you.
+
::<> Show Message:  Very well, good day to you.}}
-
</td></tr></table>
+
There are a few things that you can do to add to the system.  You can add interest so that the player's money grows.  You do this by doing the following (adds 1% to Bank Money).
There are a few things that you can do to add to the system.  You can add interest so that the player's money grows.  You do this by doing the following (adds 1% to Bank Money).
-
<table border='0' align='center' width='90%' cellpadding='3' cellspacing='1' style="background-color:#000066;"><tr><td style='BORDER: #000000 1px solid; BACKGROUND-COLOR: #000099; color:#FFFFFF; font-family:Verdana; font-size:8pt;'>
+
{{code|code=<> Change Variable: [0004: Interest] set [0002: Bank Money] value<br />
-
<> Change Variable: [0004: Interest] set [0002: Bank Money] value<br />
+
<> Change Variable: [0004: Interest] divide by 100<br />
<> Change Variable: [0004: Interest] divide by 100<br />
-
<> Change Variable: [0002: Bank Money] add [0004: Interest] value
+
<> Change Variable: [0002: Bank Money] add [0004: Interest] value}}
-
</td></tr></table>
+
Do this at the end of every battle, at the end of every day (if you're using a day/night system), or any other time you see fit.
Do this at the end of every battle, at the end of every day (if you're using a day/night system), or any other time you see fit.

Revision as of 13:41, 3 February 2007

Bank Tutorial
Written by: Daetyrnis

This tutorial outlines and explains how you can implement a bank system into your game.

Because the nature of banks is that you can withdraw your money from anywhere, you'll need several bank event locations. You will be making only one event with this tutorial, but you will need to copy and paste it to other places to get the full effect of the system.

We start by making an event that will be the actual bank system. Make it Same Level as Hero and give it the graphic of a bankteller. On the first page, we let the player decide whether they want to start an account. This is simple enough. Place a 'Show Message' command followed by a 'Show Choice' command to get this done. What we get is something like this.

RPGM Code:
Event: {{{evntname}}}

<> Show Message: Welcome to the bank. Would you like to start an account?
<> Show Choices: Yes/No

[Yes] Handler
<> Change Switch: [0001:Bank Account] - ON
<> Show Message: Your account has been made
[No] Handler
<> Show Message: Very well, good day to you.


You can add to this later, but for now, it fits our purposes. Remember that along with the following code, this should be included in every bank event. The player could decide to start an account at any given time.

Now we need the player to be able to withdraw and deposit their money. For this we will need a total of 3 variables. We'll call them

RPGM Code:
Event: {{{evntname}}}

Variable [0001: Current Money]
Variable [0002: Bank Money]

Variable [0003: Bank Input]


Current Money will store the amount of money that the player currently has. Bank Money will be the running total of money stored in the bank system. And Bank Input will be what we use for the player to decide how much money to withdraw or deposit.

Now, lets make the actual bank system: the part that allows the player to withdraw and deposit their money at will. Make a new page in the event, giving it the prerequisite of Switch[0001:Bank Account] - ON. We start with a choice of withdrawing, depositing, or doing nothing. A good thing to do is show the player how much money they currently have by using '\\$'. We also show the amount of money in the bank by using '\\v[2]' to show the current value of the second variable: Bank Money.

RPGM Code:
Event: {{{evntname}}}

<> Show Message: Welcome to the bank. What would you like to do?
<> Show Message: \\$Your account currently has \\v[1] gold in it.
<> Show Choices: Withdraw/Deposit/Nothing

[Withdraw] Handler

...

[Deposit] Handler

...

[Nothing] Handler
<> Show Message: Very well, good day to you.


Let's begin with what happens upon choosing Withdraw. First, show a message asking how much to withdraw, along with showing the player's current money and bank money. Then we use a a'Input Number' command so the player can choose the amount.

RPGM Code:
Event: {{{evntname}}}

<> Show Message: \\$You have \\v[2] gold in the bank. How much do you wish to withdraw?

<> Input Number: 6 digits [0003: Bank Input]


Next, we have to make sure the player isn't withdrawing more money than they have in the bank. We do this with a simple conditional fork.

RPGM Code:
Event: {{{evntname}}}

<>Fork Option: Var[0003: Bank Input] equal to or less than Var[0002: Bank Money]
...
ELSE case

<> Show Message: Sorry, you don't have that much to withdraw.


If all is fine, then we subtract Bank Input from Bank Money and add Bank Input to the player's money.

RPGM Code:
Event: {{{evntname}}}

<> Change Variable: [0002: Bank Money] minus [0003: Bank Input] value

<> Change Money: Increase by [0003: Bank Input] value


So all together, withdrawing will look like this.

RPGM Code:
Event: {{{evntname}}}

<> Show Message: \\$You have \\v[2] gold in the bank. How much do you wish to withdraw?
<> Input Number: 6 digits [0003: Bank Input]
<>Fork Option: Var[0003: Bank Input] equal to or less than Var[0002: Bank Money]

<> Change Variable: [0002: Bank Money] minus [0003: Bank Input] value
<> Change Money: Increase by [0003: Bank Input] value

ELSE case

<> Show Message: Sorry, you don't have that much to withdraw.


Depositing is very similar. The only differences are that you have to assign the player's money to a variable, and check that the input is lower than that. And of course how it affects the player's money.

RPGM Code:
Event: {{{evntname}}}

<> Show Message: \\$You have \\v[2] gold in the bank. How much do you wish to deposit?
<> Input Number: 6 digits [0003: Bank Input]
<> Change Variable [0001: Current Money] set Money value
<>Fork Option: Var[0003: Bank Input] equal to or less than Var[0001: Current Money]

<> Change Variable: [0002: Bank Money] add [0003: Bank Input] value
<> Change Money: Decrease by [0003: Bank Input] value

ELSE case

<> Show Message: Sorry, you don't have that much to deposit.


All together...

RPGM Code:
Event: {{{evntname}}}

<> Show Message: Welcome to the bank. What would you like to do?
<> Show Message: \\$Your account currently has \\v[1] gold in it.
<> Show Choices: Withdraw/Deposit/Nothing

[Withdraw] Handler
<> Show Message: \\$You have \\v[2] gold in the bank. How much do you wish to withdraw?
<> Input Number: 6 digits [0003: Bank Input]
<>Fork Option: Var[0003: Bank Input] equal to or less than Var[0002: Bank Money]
<> Change Variable: [0002: Bank Money] minus [0003: Bank Input] value
<> Change Money: Increase by [0003: Bank Input] value
ELSE case
<> Show Message: Sorry, you don't have that much to withdraw.
[Deposit] Handler
<> Show Message: \\$You have \\v[2] gold in the bank. How much do you wish to deposit?
<> Input Number: 6 digits [0003: Bank Input]
<> Change Variable [0001: Current Money] set Money value
<>Fork Option: Var[0003: Bank Input] equal to or less than Var[0001: Current Money]
<> Change Variable: [0002: Bank Money] add [0003: Bank Input] value
<> Change Money: Decrease by [0003: Bank Input] value
ELSE case
<> Show Message: Sorry, you don't have that much to deposit.
[Nothing] Handler
<> Show Message: Very well, good day to you.


There are a few things that you can do to add to the system. You can add interest so that the player's money grows. You do this by doing the following (adds 1% to Bank Money).

RPGM Code:
Event: {{{evntname}}}

<> Change Variable: [0004: Interest] set [0002: Bank Money] value
<> Change Variable: [0004: Interest] divide by 100

<> Change Variable: [0002: Bank Money] add [0004: Interest] value


Do this at the end of every battle, at the end of every day (if you're using a day/night system), or any other time you see fit.


Also, you can give the player certain benefits in the form of items. These items can range from common potions to rare items only obtainable with the bank. Examples of times to give items are

  • Upon starting an account
  • Reaching certain levels of deposited money (such as 1000, 5000, 10000, 20000, etc.)
  • Being a member of the bank for a long time (usually requires day/night system)

There are more things that you can add to spice up your bank, as these are only the basics.

Personal tools