How to create an ATM system (banking system) for game

So basically I created a shop for my game, but then I want to create a banking system for my game with a working ATM that withdraws and deposits money and collects banking interest… Except how would one go about this momentous task?

Do you want the ATM to be always there or just in specific moments as a choice?

Maybe something like-

*create money 500
*create moneyinbank 400

*label atm
*choice
  #Withdraw
    *choice
       #10
         *if moneyinbank >= 10
            You withdrew 10 bucks
            *set moneyinbank - 10
            *set money + 10
            *goto atm
        *else
            You don't have enough money to withdraw
            *goto atm
       #20
            You withdrew 10 bucks
           *if moneyinbank >= 20
              *set money + 20
               *set moneyinbank - 20
            *goto atm
        *else
            You don't have enough money to withdraw
            *goto atm
       #etc. 
         *if moneyinbank >= whatever
           *set money + whatever
            *goto atm
        *else
            You don't have enough money to withdraw
            *goto atm
 #Deposit
    *choice
       #10
         *if money >= 10
           *set money - 10
           *set moneyinbank + 10
            *goto atm
        *else
            You don't have enough money to deposit
            *goto atm
       #20
         *if money =< 20
           *set money - 20
           *set moneyinbank + 20
            *goto atm
        *else
            You don't have enough money to deposit
            *goto atm
       #etc. 
           You deposited whatever amount
           *set money + whatever
            *goto atm
  #I'm done with the atm
     *goto somewhere_else


the >= stuff might need to be messed with because I never get them right the first time.

Forgot to do the interest. But basically it depends on how you intend to do it. Is it going to be an over time scenario, or when it’s deposited?

fixed some variables

The bank interest is going to accumulate over time…

How do you have the time set up? Do you have a variable to trigger days passing? (Like, say, day + 1 for each day, or something else?)

*label hourtime
*if minutes > 60
*set hour + 1
*set minutes = 00
goto hours

*label hours
${hour} hour had passed.
*if hour >= 24
*set hour = 0
*set minutes = 01
*set day + 1
*set night + 1

Plus the normal “Days of the Week” format, which is too long to put here

Gotcha, gotcha.

One way to do it is set the moneyinbank variable to increase every time it reaches a certain point in time. (which, you should be able to set under *label hours.

Bear with me since I’ve never had a bank account collect interest so I don’t know rates or anything.

Say, you wanted it to collect a dollar a day- set a variable that equals 1 that rolls over every morning. For each hour = #, when it triggers that variable it can add an extra dollar. For instance, I did a quick test in my game and set it up like this -

*label atm
You have ${moneyinbank} in the bank.
*choice
	#Withdraw
		*choice
			#10
				*if moneyinbank >= 10
					You withdrew 10 bucks
					*set moneyinbank - 10
					*set money + 10
					*goto atm
				*else
					*goto atm

	#Deposit
		*choice
			#10
				*if money >= 10
					*set money - 10
					*set moneyinbank + 10
					*goto atm
				*else
					You don't have enough money to deposit
					*goto atm
      
	#I'm done with the atm
		*goto main
	

And then during my time change, I have this-

*label time
*if dot = 1
	*set moneyinbank + 1
*return (I have it as a gosub)

dot equals Day of Time. So basically, every time it’s morning, it triggers, adding a dollar every day. Though, you could have it as, say,

*if hour = 6
     *set moneyinbank + 1
*goto whereever

Make sense?

The only problem with this is if you go to an atm, back out and then go back it’s going to add an extra dollar. You could add something to fix that, such as every time you back out of the atm, it adds an hour. or, since you have minutes, adding a minute so it’s not exactly the same as the trigger.

If you want to have simple/compound interest, you could set up a subroutine that is triggered every time you advance your time variable. For example:

*set day +1
*gosub bank_interest

*label bank_interest
*set money_in_bank * interest_rate
*return

This would be independent of your atm interface. But since ‘money_in_bank’ is a declared variable, you should be able to interact with it easily enough in the atm page via withdrawals/deposits/etc. Hope this helps!

2 Likes

*Rubs chin

Is the interest simple/fixed, or is it compound (as in my language: interesting interest)?

Hmmm, another way of going about this might be to have the money in the bank collect interest at certain checkpoints in the game.

I’m not sure how realistic you’re wanting to have the game be, but it seems reasonable that, say, at the end of every chapter, you have a “your balance was ___. At the end of this week/month/year, with your agreed upon interest rate of 1%, you will have ____”

See, with interest constantly accruing, unless you have a very accurate subroutine, I could see it being something where, every time the player checks the bank, their money increases. It’s easy to accidentally create those loopholes, when you’re doing something this complex, whereas, with the “only at checkpoints” method, you have simpler coding, as well as a reduced risk of players gaming the system, so to speak.

3 Likes