added new machines

This commit is contained in:
Rainer 2025-08-22 02:10:35 +02:00
parent ceb168de55
commit 8603834f56
35 changed files with 2223 additions and 1204 deletions

190
README.md
View file

@ -1,146 +1,68 @@
# Bank Accounts (Redo & Extended)
# bank_accounts
This mod adds an ATM, card swipe, debit and credit cards to Minetest.
A complete overhaul and extension of the original `bank_accounts` mod by Tmanyo (Trent Lasich). This project has been restructured from the ground up to ensure stability, security, and a significantly expanded feature set.
# Important
To get an ATM, you must have the give priv. Type "/giveme bank_accounts:atm". I designed it this way to prevent buildings from being built out of ATMs. I want the mod to be realistic, and buildings made out of ATMs are not realistic.
## About This Version
If you have privs priv. When you grant yourself all, you will be given "seized" priv. Revoke it, else your account will be seized.
This version is a "Redo" of the original code. The focus was on fixing critical bugs, preventing exploits, and drastically improving stability, especially in multiplayer environments. Furthermore, numerous new features such as an automatic interest system, a detailed account statement, and a wire transfer machine have been added to provide a comprehensive in-game economic system.
Credits:
- NathanS21 for textures and models.
- Tmanyo for code.
## Features Overview
This mod uses the currency mod to provide different ways of paying for items in Minetest.
- Debit card
- Credit Card
* **Complete Account System:** Players automatically receive an account with a balance and a credit line.
* **5 Interactive Machines:** ATM, Teller Computer, PIN Terminal, Card Swipe, and Wire Transfer Machine (WTM).
* **Detailed Account Statement:** All transactions are logged and can be viewed via the ATM or Teller Computer.
* **Automatic Interest System:** A performant background process calculates daily interest on balances and credit debts.
* **Secure Transactions:** All actions are secured against exploits (e.g., duplication bugs) and invalid inputs.
* **API for Other Mods:** Allows other mods to safely interact with the banking system.
* **Fully Translatable (i18n):** All texts can be easily adapted for other languages.
All Items:
- ATM (Automatic Teller Machine)
- Card-Swipe
- ATM Card
- Debit Card
- Credit Card
## Dependencies
Chatcommands:
- All players:
- /set_pin #### (Set your Personal Identification Number)
- Admins:
- /account_balance {name} {number} | (Set a player's account balance)
- /wipe {name} | (Clear a player's bank account)
- /forgive {name} | (Clear a player's credit debt)
- /add {name} {number} | (Add to a player's account balance)
- /subtract {name} {number} | (Subtract from a player's account balance)
- /seize {name} | (Seize a player's account)
- /unseize {name} | (Unseize a player's account)
This mod requires the **Currency Mod** to function.
* **ContentDB Link:** [https://content.luanti.org/packages/mt-mods/currency/](https://content.luanti.org/packages/mt-mods/currency/)
Privileges:
- bank_teller (Allows players to use a Bank Teller's Computer. You should only give this to trusted individuals.)
- unseized (If you have this, your account is not seized.)
## Known Issues & WIP
With a debit card, when you buy an item through a card-swipe, it automatically takes money that you have deposited out of your account.
With a credit card, when you buy an item through a card-swipe, it builds up credit debt. There is a recommended monthly credit payment.
If you don't pay the payment, version 1.0 of this mod will not penalize you. It is more incentive to pay off your credit debt. Admins
can look at your credit debt and determine what they want to do. Either way, the person you bought goods from gets their money. Admins
can seize your ability to buy items with credit.
This version is significantly more stable than the original mod, especially on multiplayer servers. Most critical multiplayer bugs and data loss issues have been resolved.
To view your account statistics, you can find an ATM or Automatic Teller Machine. If you don't already have a PIN (Personal Identification
Number), you can get one by using /set_pin ####. Replace # with a number. I don't recommend using a number that is important to you because
the admins can see it. Once you set your PIN, you are given an ATM card which allows you to access your account. Right click the ATM with
your ATM card and enter your PIN. You can then see your account balance, total credit debt, and your monthly credit payment. If you want
to raise your account balance, you can click deposit and place currency in the correct box for each bill. It will automatically add up
and be added to your balance. You can't cheat and place other objects in the boxes, that is insured not to happen. If you want to withdraw
money from your account, click withdraw and enter the amount. Don't worry you can't recieve a larger amount of money than is in your account.
You can pay credit debt off by clicking the "Pay Monthly Credit Payment" button. You have an option to pay the monthly amount or more.
You can get a credit and debit card by clicking on each button on the home screen of the ATM. Just because you may have 20 of each card
doesn't make a difference. You are not any more wealthy than you are with just one of each.
However, there is a known theoretical race condition that can occur under very specific circumstances:
* **If two different players interact with two different machines (e.g., two ATMs) at the exact same moment, it is possible for a transaction to be misdirected to the wrong machine.**
When using a card-swipe, the owner is the seller. The owner must right click the node first and enter a price for the item(s). Then the
owner needs to place the item(s) within the top 8 set of boxes and click enter. The buyer then right clicks the node and removes the item(s)
from the top 8 boxes and places them in their own inventory and then clicks enter. If you are trying to use a debit card and it won't let
you see the screen, that means you do not have enough money on your account. At this point, you can use your credit card, but don't forget
to pay it off.
The time window for this to occur is extremely small (typically less than a few seconds between the two players' clicks), making it a very rare event on most servers.
You can view use of the chatcommands by viewing the chatcommands.lua file.
This mod is under development still, so there may be some issues.
You can reach the mod creator on irc.inchra.net - #RRHMS-DownDeep or Freenode irc - #minetest.
This is a known limitation resulting from a workaround needed to ensure stability across different Minetest clients. It is considered a work-in-progress (WIP) issue that may be addressed in future updates.
## Getting Started (For Players)
To use the banking system, you first need to set your personal PIN.
1. Find a **PIN Terminal** (a small, wall-mounted device).
2. Right-click it. As a new customer, you will be prompted to set a 4-digit PIN.
3. After successful entry, you will automatically receive your **Bank Card** (`ATM Card`) in your inventory. You will need this card to access most of the other machines.
## The Machines (Nodes) in Detail
### PIN Terminal
* **Purpose:** The primary point of contact for new players and for PIN management.
* **Functions:**
* **New Players:** Are prompted to set their first, personal 4-digit PIN. They then receive their first bank card.
* **Existing Players:** Can change their PIN (requires entering the old PIN for security) or request a new bank card if the old one was lost.
### ATM (Automatic Teller Machine)
* **Purpose:** Standard interactions with one's own account.
* **Operation:** Requires a Bank Card (`ATM Card`) and PIN entry.
* **Functions:**
* **Deposit:** Deposit cash (`currency` items).
* **Withdrawal:** Withdraw cash (integers only).
* **Pay Credit:** Provides the option to pay the due rate or a custom amount of the credit debt.
* **Account Statement:** Shows the transaction history for balance and credit.
* **Request Cards:** Issues new debit or credit cards.
### Teller Computer
* **Purpose:** For players with the `bank_teller` privilege to manage customer accounts.
* **Functions:**
* All functions of a normal ATM, but for any customer entered by name.
* Additional admin functions: Wipe Account and Reset PIN.
* Admin Search (Shift + Right-click): Server admins can check if an account is seized.
### Wire Transfer Machine (WTM)
* **Purpose:** Secure money transfers between players.
* **Operation:** Requires Bank Card and PIN.
* **Functions:**
* Transfer from your balance.
* Transfer from your credit line.
* Input fields for **Recipient**, **Amount** (decimals allowed), and **Purpose**.
* The recipient receives a chat message about the incoming funds.
* The transaction is logged in the account statements of both the sender and the recipient with all details.
### Card Swipe
* **Purpose:** Player-owned shops to sell items via card payment.
* **Functions:**
* **Seller:** Places the device, puts items in its inventory, and sets a price (decimals allowed).
* **Buyer:** Right-clicks the device with a debit or credit card to complete the purchase. The process is theft-proof items are only transferred automatically after successful payment.
## Automatic Interest System (`interest.lua`)
* A performant background process calculates interest once every 24 hours (real-time).
* The interest rates for balance (default 0.5%) and credit debt (default 3%) can be easily configured at the beginning of the `interest.lua` file.
* Interest transactions are automatically logged in the account statement.
## Chat Commands
All commands start with `bank_`.
#### For All Players
* `/bank_account [<playername>]` - Shows your own account balance. Players with `bank_teller` or `server` privs can also view others' accounts.
* `/bank_set_pin <4-digit-PIN>` - Sets your own PIN. (Replaced in function by the PIN Terminal but remains as a command).
#### For Admins Only (`server` privilege)
* `/bank_add <name> <number>` - Adds money to a player's account (integers only).
* `/bank_subtract <name> <number>` - Subtracts money from a player's account (integers only).
* `/bank_balance <name> <number>` - Sets a player's balance to an exact value (decimals allowed).
* `/bank_credit <name> <number>` - Sets a player's credit debt to an exact value (decimals allowed). `/bank_credit <name> 0` forgives all debt.
* `/bank_wipe <name>` - Wipes a player's account balance to 0.
* `/bank_seize <name>` - Seizes a player's account (locks access).
* `/bank_unseize <name>` - Unseizes an account.
## Improvements Over the Original Version
* **Stability:** The fundamental logic was overhauled to fix crashes and "freezing" or silently closing windows.
* **Security / Exploits:** Numerous exploits have been fixed, e.g., money duplication by moving items between slots, and withdrawing fractional amounts of cash.
* **Multiplayer Capability:** Almost all global variables that caused conflicts between players have been removed. The mod is now significantly more stable on servers. *(Note: One global variable for position was retained for compatibility with certain Minetest clients, which could in theory cause issues with perfectly simultaneous interactions at two devices, but this is extremely unlikely in practice).*
* **API:** A clean and safe API in `functions.lua` now allows other mods to interact with the system easily and without conflicts.
* **New Features:** Account Statements, Daily Interest System, Wire Transfer Machine, and the PIN Terminal have been newly added.
* **User Experience:** The onboarding for new players via the PIN Terminal is much more immersive. The UI has been polished in many places.
* **Internationalization (i18n):** The entire mod is now fully translatable.
---
## License
```
License: MIT
Copyright 2016 Trent Lasich
Copyright 2025 Rage87
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```
## Credits
* Original Mod: Tmanyo (Trent Lasich)
* Complete Redo, Extension & Bugfixing: **Rage87**
Bank Teller's Computer:
- This is used by people who have the bank_teller privilege. It has all the features an ATM does and allows for wiping a player's account, forgiving credit debt, reseting PINs, and over-viewing player's account statistics. If you are an admin, you can press E and rightclick this node, to search player names to check if they are seized or not.