Hey there users! If you’ve been watching (aka reading), you would know that I made a credit card system a while ago. Well, I decided to add another branch that is kind of related to it, the ATM!
You know the drill, we’ll go through our goals!
Our Goal
- Make an ATM capable of placing and withdrawing cash.
- Have it be able to give you hard cash.
- Create an ID array so the ATM can correctly place money in the correct card.
Let’s get started!
The ATM itself.
Okay, obviously, we need the ATM itself or else, where would you place your money in?
Made it myself!
Now, you don’t need to follow, this, if you don’t want to recreate it, use a prop and call it an ATM, it doesn’t matter what you use, so long as you have an ATM.
The Software
Getting a Credit Card
Our first goal will be to make an array of ID’s and have the ATM keep track of them.
For now, we’ll make 3 properties and name them card1, card2, and card3. Make them text properties and have them set to notClaimed. Then, make another property called runThroughCards. This property will help us cycle through the cards when getting our new cards and for the ATM to figure out which card is doing the transaction.
For fun, we’ll make a way for people to get a credit card. Make a button and wire it to a trigger. In the ‘when triggered block’, add this.
What this does is that a variable called checkingOpenCards is set to runThroughCards. Then, we run an if/else statement checking if our card property has not been claimed. We concatenate the card and the number value of our variable to be able to make a cycle for the system to go through all the cards. The if checks if the current card property has not been claimed, if your lucky, it updates the property with the player’s name, it then resets the property. So ‘Samantha’ might own Card1, while ‘Jerry’, owns Card2. Our else is in case our card has already been claimed if so, it updates the variable by 1 and calls the trigger again (hence the checkAgain broadcast, make sure your trigger is triggered by it).
You should have this so far.
Withdrawing and Depositing
We’ll first make the withdrawing part of the system. Make a button, and call it Withdraw $10?. If you’re smart enough, you should know that we’ll be withdrawing $10. For now, let’s make our ‘bank account’. Make 3 properties called BankAccount1, BankAccount2, and BankAccount3. Make them number properties and place any amount of money in them. Make sure they are not the same, to keep it realistic. Once you are done, make that button we just made in front of the ATM. Wire it to a trigger and put this code in it.
This works basically the same as getting a card one. It cycles through the cards, except, it checks which card has your name in it. Then it runs the transaction of ‘removing’ $10 dollars from your account. The only thing that wasn’t mentioned was that it needed to broadcast on giveMoney, which would be received by an item granter that would grant cash, 10 cash to be precise. We also have an else statement in case you don’t have enough money in your account, in which case it would broadcast to a notification or pop-up saying that you can’t do the transaction. The checkAgain2 triggers the trigger, which helps it cycle through the cards.
Depositing
It is the EXACT same as the withdrawal, except you are adding $10 to your bank account. However, we have a checker that is wired to the button. We want it to check if the amount of cash the player has is less than 10, if the check passes, meaning they have less then 10 dollars, broadcast on cannotDoTransaction which would probably open a message saying you don’t have the money to put it in. And if the check fails, which means they have 10 or more, broadcast oncanDoTransaction. Here is a model of how it would technically work.
And that should be it! If I missed anything or if something doesn’t work, let me know.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5