Career Payment Module
M.dependencies = {'career_career'}
Dependencies
M.dependencies = {'career_career'}Thin payment gateway for career mode. Validates multi-currency affordability and deducts amounts via playerAttributes.
Public API
| Function | Signature | Description |
|---|---|---|
M.canPay | (price) → bool | Checks if player can afford the price across all currencies |
M.pay | (price, reason) → bool | Deducts price from player attributes; returns false if insufficient funds |
Dependencies
career_career(required)career_modules_playerAttributes- attribute value queries and mutations
Price Format
Price is a table keyed by currency name. Each entry has amount and optional canBeNegative:
local price = {
money = {amount = 500, canBeNegative = false},
-- can include other currencies:
-- someOrgReputation = {amount = 10, canBeNegative = true},
}When canBeNegative is true (or absent), the check is skipped for that currency-allowing the balance to go negative.
Usage Example
local price = {money = {amount = 1500, canBeNegative = false}}
if career_modules_payment.canPay(price) then
career_modules_payment.pay(price, {
label = "Bought new engine",
tags = {"partsBought", "buying"}
})
endInternal Flow
canPayiterates each currency key inprice- Skips check if
canBeNegativeis true or amount ≤ 0 - Compares against
playerAttributes.getAttributeValue(currency) paycallsplayerAttributes.addAttributeswith negated amounts
See Also
- playerAttributes - Underlying attribute storage
- partShopping - Uses payment for part purchases
- painting - Uses payment for paint jobs
Career Part Shopping Module
Interactive part shop UI for buying, swapping, and removing vehicle parts at garage computers. Maintains a preview vehicle, shopping cart with 7% sales tax, and inventory-part reuse. Uses a tether sys
Career Permissions Module
Centralized permission system for career actions. Other modules hook into `onCheckPermission` to grant or restrict actions based on active gameplay state (e.g., missions, deliveries, tutorials).