API ReferenceGE Extensionscareermodules
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
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 system to cancel shopping if the player walks too far away.
Public API
| Function | Signature | Description |
|---|---|---|
M.startShopping | (inventoryId, originComputerId) | Opens part shop for a vehicle; auto-repairs first if needed |
M.installPart | (part) | Adds a part to preview vehicle and shopping cart |
M.installPartByPartShopId | (partShopId) | Installs a part by its temporary shop ID |
M.removePartBySlot | (slot) | Removes a shopping-cart part by slot path |
M.updatePreviewVehicle | (currentPartConditions) | Callback to refresh preview after vehicle config reload |
M.cancelShopping | () | Reverts vehicle to original config and exits |
M.applyShopping | () | Pays total, commits changes, triggers save |
M.sendShoppingDataToUI | () | Pushes full shop data (parts, tree, cart, search) to UI |
M.getPartsInShop | () → table | Returns all available shop parts |
M.getShoppingCart | () → table | Returns current shopping cart |
M.isShoppingSessionActive | () → bool | Whether a shopping session is in progress |
M.setupTether | () | Creates capsule tether between computer and vehicle |
M.onComputerAddFunctions | (menuData, computerFunctions) | Registers "Part Customization" button |
M.onVehicleSaveFinished | () | Closes menu after autosave |
Key Concepts
- Preview Vehicle: Deep copy of vehicle data used for live part swaps without saving
- Shopping Cart: Tracks
partsIn(new),partsOut(replaced), total + 7% tax - Part Shop IDs: Temporary sequential IDs assigned to each shop part per session
- Core Slots: Protected slots that cannot be emptied (e.g. frame)
- Tether: Capsule-shaped boundary between computer and vehicle; cancels session if player leaves
Shopping Cart Structure
shoppingCart = {
partsIn = {}, -- {[slotPath] = shopPart}
partsOut = {}, -- {[slotPath] = inventoryPart}
partsInList = {}, -- ordered list version
partsOutList = {}, -- ordered list version
slotList = {}, -- ordered slot paths
total = 1250, -- price including 7% tax
taxes = 82, -- tax amount
}Dependencies
career_modules_inventory- vehicle data, spawningcareer_modules_partInventory- existing part lookups, inventory updatescareer_modules_payment/career_modules_playerAttributes- money check / deductioncareer_modules_permissions- partBuying/vehicleModification permissioncareer_modules_tether- walk-away boundarycareer_modules_painting- primer color for new part conditionscareer_modules_valueCalculator- broken-parts checkjbeam/io,jbeam/slotSystem- part compatibility and slot info
Usage Example
-- Start shopping from computer
career_modules_partShopping.startShopping(inventoryId, computerId)
-- Install a part by shop ID from UI
career_modules_partShopping.installPartByPartShopId(42)
-- Apply and pay
career_modules_partShopping.applyShopping()Hooks Emitted
| Hook | When |
|---|---|
onPartShoppingStarted | Session begins |
onPartShoppingPartInstalled | A part is installed in preview |
onPartShoppingTransactionComplete | Purchase finalized |
See Also
- partInventory - Global part storage
- tuning - Variable-based vehicle tuning
- tether - Walk-away boundary system