API ReferenceGE Extensionscareermodulesinsurance
Insurance History
Tracks the player's insurance and repair history. Stores a chronological list of claims, renewals, coverage changes, and private repairs with their financial effects.
Tracks the player's insurance and repair history. Stores a chronological list of claims, renewals, coverage changes, and private repairs with their financial effects.
Public API
| Function | Signature | Description |
|---|---|---|
M.addToPlHistory | (data) | Adds a new entry with type, title, effects, concernedInsuranceName, overrideText, other, auto-stamps time |
M.buildPlHistory | () → table | Returns deep-copied history sorted newest-first, with formatted date strings |
M.getPlHistory | () → table | Returns raw history table reference |
M.setPlHistory | (history) | Replaces history (used during save load) |
M.initPlHistory | () | Clears history to empty table |
M.getInsuranceClaimsCount | () → number | Count of insuranceRepairClaim entries |
M.getNonInsuranceRepairsCount | () → number | Count of privateRepair entries |
M.getTotalPremiumPaid | () → number | Sum of money spent on insuranceRenewed + insuranceChanged |
M.getTotalInsuranceRepairDeductiblesPaid | () → number | Sum of all deductibles from repair claims |
M.getTotalPrivateRepairsPaid | () → number | Sum of money spent on private repairs |
M.getDamageCostCoveredByInsurance | () → number | Sum of all vehDamagePrice from insurance claims |
History Entry Structure
{
type = "insuranceRepairClaim", -- or "privateRepair", "insuranceRenewed", etc.
title = "Insurance repair claim",
effects = {
{type = "money", label = "Money", changedBy = -500, newValue = 12000},
{type = "driverScore", label = "Driver score", changedBy = -1, newValue = 63}
},
concernedInsuranceName = "SafeDrive Insurance",
overrideText = nil, -- optional display override
other = { -- type-specific extra data
vehDamagePrice = 2500,
deductible = 500
},
time = 1700000000 -- os.time() timestamp
}Known History Types
| Type | Description |
|---|---|
insuranceRepairClaim | Vehicle repaired through insurance |
privateRepair | Vehicle repaired out-of-pocket |
insuranceRenewed | Insurance policy auto-renewed |
insuranceChanged | Switched insurance provider |
testDriveClaim | Damaged a test drive vehicle |
freeRepair | Accident forgiveness gesture |
driverScoreIncrease | Safe driving bonus |
driverScoreReset | Paid to reset driver score |
insuranceCoverageChanged | Modified coverage options |
See Also
- insurance - Main insurance system (uses history for tracking)
- milestones/insurance - Milestones based on claim count