Exports
- Added
- Updated
These let your own scripts read the same figures the panel shows — a payday script that checks the money supply first, a Discord bot, a dashboard of your own.
Server side
Anything that reads a total returns nil until the first pass has finished, so check isReady — or just check what came back — before using it.
isReady
Tells you whether the figures are ready yet.
Takes no arguments. Returns boolean.
exports.REC_Economy:isReady()
getStatus
Tells you what it is still waiting for.
Takes no arguments. Returns Status:
| Field | Type | Description |
|---|---|---|
ready | boolean | |
reason | string? | waiting_item_manager / waiting_framework / starting |
resource | string? | The resource being waited on |
resourceState | string? | What state that resource is in |
exports.REC_Economy:getStatus()
getMoneys
Gives you the total of each currency.
Takes no arguments. Returns table<MoneyTypes, MetaData>?:
| Field | Type | Description |
|---|---|---|
key | MoneyTypes | cash / bank_money / black_money / crypto |
value | integer | Total of that currency |
exports.REC_Economy:getMoneys()
RegisterCommand("supply", function()
if exports.REC_Economy:isReady() == false then
return
end
for moneyType, meta in pairs(exports.REC_Economy:getMoneys()) do
print(("%s: %d"):format(moneyType, meta.value))
end
end, true)
getSocieties
Gives you every group account.
Takes no arguments. Returns table<string, SocietyMetaData>?:
| Field | Type | Description |
|---|---|---|
name | string | Society name |
label | string | Display label |
type | string? | Society type, if your bank provides one |
money | integer | Balance |
exports.REC_Economy:getSocieties()
getSnapshot
Gives you everything the dashboard opens with, in one call.
Takes no arguments. Returns Snapshot?:
| Field | Type | Description |
|---|---|---|
moneys | table<MoneyTypes, MetaData> | Same as getMoneys |
societies | table<string, SocietyMetaData> | Same as getSocieties |
updatedAt | integer | Last full rebuild |
sampledAt | integer | Last quick re-check |
onlineCount | integer | Characters online |
characterCount | integer | Characters the total is spread across |
targetDays | integer | 0 when everybody is counted |
bankSupported | boolean | false if no banking resource was found |
dormancy | Dormancy? | nil until the first scan finishes |
exports.REC_Economy:getSnapshot()
getDistribution
Gives you how evenly money is spread across your players.
Takes no arguments. Returns Distribution?:
| Field | Type | Description |
|---|---|---|
count | integer | Characters included |
total | integer | Money they hold |
mean / median | number | |
p90 / p99 | number | |
gini | number | 0 is perfectly even, 1 is one person holding everything |
top1 / top10 | number | Share held by the richest 1% and 10% |
buckets | Bucket[] | from, to (nil on the top band) and count |
lorenz | number[][] | Points for the Lorenz curve |
exports.REC_Economy:getDistribution()
getHistory
Gives you the saved totals, oldest first.
| Argument | Type | Description |
|---|---|---|
days | integer? | How far back to go. 30 by default |
Returns HistoryRow[]:
| Field | Type | Description |
|---|---|---|
moneys | table<MoneyTypes, integer> | Totals at that moment |
societyTotal | integer | |
onlineCount | integer | |
characterCount | integer | 0 on rows saved before this was recorded |
takenAt | integer |
exports.REC_Economy:getHistory(days)
getLastSnapshotAt
Tells you when the last snapshot was saved.
Takes no arguments. Returns integer?.
exports.REC_Economy:getLastSnapshotAt()
refresh
Rebuilds everything now.
Takes no arguments. Returns boolean — false if a rebuild is already running.
exports.REC_Economy:refresh()
getPlayers
Gives you character balances, filtered before they reach you.
| Argument | Type | Description |
|---|---|---|
search | string? | Matched against citizenId and name |
limit | integer? | Capped at playerList.limit |
Returns PlayersResult? — players (citizenId, name, online, moneys, total) plus matched, total, truncated and targetDays.
exports.REC_Economy:getPlayers(search, limit)
getPlayerMoneys
Gives you one character's balances, whether they are online or not.
| Argument | Type | Description |
|---|---|---|
citizenId | string |
Returns table<MoneyTypes, integer>?, and their name as a second value.
exports.REC_Economy:getPlayerMoneys(citizenId)
getFlows
Gives you what created and destroyed money, by reason and by job.
| Argument | Type | Description |
|---|---|---|
days | integer? | How far back to go. 7 by default |
Returns Flows?:
| Field | Type | Description |
|---|---|---|
reasons | Reason[] | reason, added, removed, net, events, and the previous period |
jobs | Job[] | job, added, removed, net, events, avgOnline, periods |
series | Point[] | takenAt, added, removed |
added / removed | integer | Totals for the period |
previousAdded / previousRemoved | integer | The period before this one |
pendingAdded / pendingRemoved | integer | Counted but not yet saved |
supported | boolean | Your framework reports payments |
unlabeledEvents | integer | Payments with no reason given |
totalEvents | integer | Every payment in the period |
exports.REC_Economy:getFlows(days)
getRecentFlows
Gives you money movements since you last asked, oldest first.
| Argument | Type | Description |
|---|---|---|
since | integer? | The cursor from your last call. 0 or nil starts at the newest |
Returns FlowPush? — the next cursor, the events, how many dropped off the end, and the not-yet-saved totals.
exports.REC_Economy:getRecentFlows(since)
getAlerts
Gives you what tripped, newest first.
| Argument | Type | Description |
|---|---|---|
days | integer? | How far back to go. 7 by default |
Returns Alert[]:
| Field | Type | Description |
|---|---|---|
kind | AlertKind | supply / player / society / anomaly |
subject | string | The citizenId, or total for the whole server |
label | string? | Player name, nil if it could not be read |
beforeAmount / afterAmount / delta | integer | |
sigma | number? | How far past normal, on anomaly alerts only |
detectedAt | integer? |
exports.REC_Economy:getAlerts(days)
getSocietyHistory
Gives you one group's balance over time, oldest first.
| Argument | Type | Description |
|---|---|---|
name | string | Society name |
days | integer? | How far back to go. 30 by default |
Returns a list of { money, takenAt }.
exports.REC_Economy:getSocietyHistory(name, days)
getWatchlist
Gives you who is currently being recorded.
Takes no arguments. Returns WatchEntry[]? — citizenId, label, note, addedBy, expiresAt, createdAt, expired.
exports.REC_Economy:getWatchlist()
addWatch
Starts recording everything one character does with money.
| Argument | Type | Description |
|---|---|---|
citizenId | string | |
note | string? | Why you are watching them |
addedBy | string? | Who added them |
days | integer? | How long to record for. Falls back to watchlist.defaultDays |
Returns boolean, plus an error message when it failed.
exports.REC_Economy:addWatch(citizenId, note, addedBy, days)
removeWatch
Stops recording one character.
| Argument | Type | Description |
|---|---|---|
citizenId | string |
Returns boolean.
exports.REC_Economy:removeWatch(citizenId)
getWatchEvents
Gives you everything one watched character did, newest first.
| Argument | Type | Description |
|---|---|---|
citizenId | string | |
days | integer? | How far back to go. 7 by default |
Returns WatchEvent[] — reason, moneyType, amount, isRemove, at.
exports.REC_Economy:getWatchEvents(citizenId, days)
getNotes
Gives you the notes marked on the charts, oldest first.
| Argument | Type | Description |
|---|---|---|
days | integer? | How far back to go. 30 by default |
Returns Note[] — id, text, author, at.
exports.REC_Economy:getNotes(days)
addNote
Marks a note on the charts.
| Argument | Type | Description |
|---|---|---|
text | string | Cut off at 255 characters |
author | string? | Who wrote it |
Returns boolean.
exports.REC_Economy:addNote(text, author)
deleteNote
Removes one note.
| Argument | Type | Description |
|---|---|---|
id | integer |
Returns boolean.
exports.REC_Economy:deleteNote(id)
getMoneys, getSocieties, getSnapshot and getDistribution answer instantly, so call them freely. Anything taking a days argument goes to the database, so keep those out of loops.beginActivity
Start an activity with an ID unique within the calling resource and its participants. Staff and duplicate participants are rejected.
| Arguments | Returns |
|---|---|
id: string, activity: string, citizenIds: string[] | boolean |
recordActivityMoney
Add non-negative earned/spent amounts to an active session.
| Arguments | Returns |
|---|---|
id: string, earned: number, spent: number | boolean |
endActivity
Finish an activity and store its outcome, participant-time and money totals.
| Arguments | Returns |
|---|---|
id: string, success: boolean | boolean |
recordPurchase
Record a positive quantity and non-negative total payment. paid is the total, not the unit price.
| Arguments | Returns |
|---|---|
item: string, quantity: number, paid: number, moneyType: string | boolean |
getAnalysis
Return analysis for a period (default 7 days, range 1–30) and Unix timestamp anchor. Returns nil before initialization.
| Arguments | Returns |
|---|---|
days?: number, anchor?: number | table|nil |
