wolfhacklua API 1.1 Forum

api

Version information and feature detection: ask what this build of the overlay offers before you rely on it.

since 1.0no permission needed

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: string

The API version of this build, for example "1.1".

api.major#since 1.0

api.major: integer

The major number. A different major may have removed or renamed functions.

api.minor#since 1.0

api.minor: integer

The 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.

ParameterTypeDescription
majorintegerThe major version the script needs.
minor optionalintegerThe minimum minor version. default 0
lua
api.require(1, 1)   -- needs the mem module (API 1.1)

api.has#since 1.0

api.has(feature: string): boolean

Feature detection by name.

ParameterTypeDescription
featurestringOne of the names in api.features.
ReturnsDescription
booleantrue when the feature exists in this build.
lua
if api.has("shaders") then
  log.info("shaders are available")
end
API 1.1 · source docs-src/api/api.json