Skip to content

Custom Type Extensions ​

Custom Item Types ​

You can extend these types for your specific use case:

lua
-- Custom item type for inventory
export type InventoryItem = {
    Id: string,
    Name: string,
    Rarity: "Common" | "Rare" | "Epic" | "Legendary",
    Level: number,
    Attributes: {[string]: any}?,
    AcquiredTime: number?,
    UpgradedTime: number?,
}

-- Custom plot building type
export type PlotBuilding = {
    Type: string,
    Level: number,
    Position: Vector3,
    Rotation: number,
    Upgrades: {string},
    BuiltTime: number,
    Health: number,
}

-- Extended player data with custom types
export type ExtendedPlayerData = PlayerData & {
    Inventory: {InventoryItem},
    Plot: {
        Likes: number,
        Size: number,
        Buildings: {[string]: PlotBuilding},
    },
    Stats: {
        TotalPlayTime: number,
        GamesPlayed: number,
        HighScore: number,
        RecentScores: {number},
    }
}

-- Batch operation with custom validation
export type ValidatedBatchOperation = BatchOperation & {
    validate: () -> boolean,
    description: string,
}

PlayerState - High-Performance Roblox Data Management