Skip to content

ContentAsset

Type

ContentAsset is one downloaded asset in memory, returned by Content.Fetch. The engine drops the least recently used asset when memory is full, so check IsValid before using an asset fetched earlier.

Id

Field
Id: string

Id is the asset id as a string of decimal digits.

Type

Field
Type: ContentType

Type is the asset's ContentType ("Scene", "Texture", "Audio", or "Mesh"), or "Unknown" for an unrecognized asset type. Content.Spawn spawns only "Scene" assets.

Example

-- Server script.
local status, asset = Content.Fetch("1000000000000001")
if status == "Ok" and asset and asset.Type == "Scene" then
    Content.Spawn(asset)
end

Size

Field
Size: number

Size is the size of the downloaded asset in bytes.

IsValid

Method
IsValid() -> boolean

IsValid returns true while the asset is still in memory.

Example

-- Server script: spawn the obstacle course again each round.
local status, course = Content.Fetch("1000000000000001")
if status ~= "Ok" then
    course = nil
end

while true do
    task.wait(60)
    if course and course:IsValid() then
        Content.Spawn(course)
    end
end

ReadBuffer

Method
ReadBuffer() -> buffer?

ReadBuffer returns a buffer containing a copy of the downloaded asset bytes, or nil when the asset is not in memory.