Link Search Menu Expand Document

Asset

Represents data that can be shared to other clients in the Alloverse

An asset is just raw data.

Constructor

 asset = Asset(data)

Arguments

Name Type Description
data string Raw data for the asset.

Returns

Nothing


Methods

asset:read (offset, length)

Read a part of the data

Arguments

Name Type Description
offset number The byte to start reading from
length number The number of bytes to read

Returns

Type Description
string the requested data

asset:write (data, offset, totalSize)

Write a part of the data

Arguments

Name Type Description
data string The data buffering
offset number The byte offset to start writing at
totalSize number The expected total size of the asset.

Returns

Nothing


asset:size ()

Returns the size of the asset

Arguments

None

Returns

Type Description
number The size of the data

asset:getImageWidthHeight ()

Returns the pixel width and height of the asset that represents an image. Returns nil if the asset doesn’t represent an image.

Arguments

None

Returns

Type Description
(number, number) The width and height of the image (in pixels)

asset:id (refresh)

Returns a computed unique identifier for this asset The id is a hash of the asset data. This ensures the same asset identifier is always matched with the same data

Arguments

Name Type Description
refresh boolean By default a cached hash is returned, if one is available. Send refresh to true to recompute the id

Returns

Nothing


asset:like_file ()

Returns a File-like wrapper to send to methods that wants files It’s not fully implemented; Fill out methods as needed.

Arguments

None

Returns

Type Description
FileWrapper An object that implmeents the same methods as io.File