Skip to content

UserVars

The UserVars library contains wrapper methods for working with UserVars and ModVars. It allows fetching definitions of variables as well as their values.

You may also define default values to return if a variable is unset on the component/modvar.

UserVarsLib_UserVar Class

@field ID string

@field Client boolean

@field Server boolean

@field WriteableOnServer boolean Defaults to `true`.

@field WriteableOnClient boolean Defaults to `false`.

@field Persistent boolean

@field SyncToClient boolean Defaults to `true`.

@field SyncToServer boolean Defaults to `true`.

@field SyncOnWrite boolean Defaults to `false`.

@field SyncOnTick boolean Defaults to `true`.

@field DontCache boolean Defaults to `false`

@field DefaultValue any?

UserVarsLib Class

Inherits from Library.

Methods

GetModVarDefinition
function UserVarsLib.GetModVarDefinition(modGUID, var)
   -> UserVarsLib_ModVar

Returns the definition of a mod variable.

@param modGUID GUID

@param var string

GetModVarValue
function UserVarsLib.GetModVarValue(modGUID, varName)
   -> any? -- Defaults to `DefaultValue`.

Returns the value of a mod var.

@param modGUID GUID

@param varName string

GetModVariables
function UserVarsLib.GetModVariables(modGUID)
   -> table

Returns the mod variables of a mod.

@param modGUID GUID

GetUserVarDefinition
function UserVarsLib.GetUserVarDefinition(varName)
   -> UserVarsLib_UserVar

Returns the definition of a user variable.

@param varName string

GetUserVarValue
function UserVarsLib.GetUserVarValue(component, varName)
   -> any? -- Defaults to `DefaultValue`.

Returns the value of a user variable for an entity.

@param component UserVarsLib_CompatibleComponent

@param varName string

RegisterModVariable
function UserVarsLib.RegisterModVariable(modGUID, name, data)
   -> UserVarsLib_ModVar

Registers a mod variable.

@param modGUID GUID

@param name string

@param data UserVarsLib_ModVar? Defaults to default values (see class).

RegisterUserVariable
function UserVarsLib.RegisterUserVariable(name, data)
   -> UserVarsLib_UserVar

Registers a user variable.

Must be done once for each context where you want the variable to exist.

@param name string

@param data UserVarsLib_UserVar? Defaults to default values (see class).