api
Version information and feature detection: ask what this build of the overlay offers before you rely on it.
The API version is major.minor. A script names the version it was written for in its manifest ("api"); the host refuses a script whose major differs or whose minor is newer than its own. These functions let a script check at run time as well.
Reference#
api.version#since 1.0
api.version: stringThe API version of this build, for example "1.1".
api.major#since 1.0
api.major: integerThe major number. A different major may have removed or renamed functions.
api.minor#since 1.0
api.minor: integerThe minor number. A newer minor only adds functions.
api.features#since 1.0
api.features: string[]The feature names api.has knows: ui, draw, textures, fonts, shaders, model_preview, widgets, themes, media, data, net, tasks, timers, store, files, json, anim, input, mem.
api.require#since 1.0
api.require(major: integer, minor?: integer)Raises an error when this build cannot run an API that new. Put it at the top of a script that uses something recent.
| Parameter | Type | Description |
|---|---|---|
major | integer | The major version the script needs. |
minor optional | integer | The minimum minor version. default 0 |
api.require(1, 1) -- needs the mem module (API 1.1)api.has#since 1.0
api.has(feature: string): booleanFeature detection by name.
| Parameter | Type | Description |
|---|---|---|
feature | string | One of the names in api.features. |
| Returns | Description |
|---|---|
boolean | true when the feature exists in this build. |
if api.has("shaders") then
log.info("shaders are available")
end