Which tab to open. Defaults to 'collectables' if not specified or invalid.
Examples
-- Open to the collectables tab (default)exports.mad_collectables:openUI()-- Open directly to the leaderboardexports.mad_collectables:openUI('leaderboard')-- Open directly to the collectablesexports.mad_collectables:openUI('collectables')
Use with Inventory
The stickerbook inventory item uses this export:
closeUI
Closes the collectables UI.
getPersonalStats
Gets the current player's collectable stats
returns: table | nil
Returns a table containing the current player's collectable statistics, or nil if data couldn't be loaded
{
displayName = string, -- Player's display name
totalCollected = number, -- Total collectables collected
totalAvailable = number, -- Total collectables available
setsCompleted = number, -- Number of completed sets
totalSets = number, -- Total number of sets
optedIn = boolean, -- Whether player opted into leaderboard
rank = number, -- Player's leaderboard rank (if opted in)
sets = { -- Array of collectable sets
{
key = string, -- Set identifier
label = string, -- Display name of the set
description = string, -- Set description
icon = string, -- Icon filename
totalItems = number, -- Total items in set
collectedCount = number, -- Number collected in this set
isCompleted = boolean, -- Whether set is complete
items = { -- Array of items in set
{
id = string, -- Item identifier
index = number, -- Item index in set
setKey = string, -- Parent set key
hint = string, -- Location hint
collected = boolean, -- Whether collected
collectedAt = number?, -- Unix timestamp (ms) when collected
placed = boolean?, -- Whether sticker placed in album
placedAt = string? -- ISO timestamp when placed
}
}
}
}
}
-- Get current player's stats
local stats = exports.mad_collectables:getPersonalStats()
if stats then
lib.print.info(('You have collected %d/%d collectables'):format(
stats.totalCollected,
stats.totalAvailable
))
for _, set in ipairs(stats.sets) do
for _, item in ipairs(set.items) do
if item.id == 'cowboy_hats_1' and not item.collected then
lib.print.info(('Hint: %s'):format(item.hint))
end
end
end
else
lib.print.error('Failed to load stats')
end
-- Example Output
You have collected 2/10 collectables
Hint: This fella got hurt, must have left his hat outside the hospital