Resource
const resource = require("@vectarine/resource")Functions common to all resources
A resource is an external piece of data. Use the loader module to load resources. You shouldn’t need to import this module.
Resource
Section titled “Resource”export type Resource = ...Resource:getStatus
Section titled “Resource:getStatus”Resource:getStatus(): string | "NotLoaded" | "Loading" | "Loaded"Get the status of a resource.
When loadResource is called, the resource is created in an Unloaded state.
Once per frame, "Unloaded" resources are scheduled for loading, and their state becomes "Loading".
When the loading is finished, the state becomes "Loaded" or "Error: Description of the error" if something went wrong.
When a resource which is not "Loaded" is used, nothing will happen and a warning will be printed in the console.
Resource:isReady
Section titled “Resource:isReady”Resource:isReady(): booleanCheck if a resource is ready to be used.
This is the same as checking if getResourceStatus returns "Loaded".
Resource:getId
Section titled “Resource:getId”Resource:getId(): numberGet the ID of a resource. The ID is a number that is unique to the resource. The ID stays constant between reloads (but not restarts!)
Returns number
ScriptResource
Section titled “ScriptResource”export type ScriptResource = ...TextResource
Section titled “TextResource”export type TextResource = ...TextResource:getText
Section titled “TextResource:getText”TextResource:getText(): string?Get the text of a text resource. Or nil if the resource is not loaded or does not exist.
Returns string?
