GetVar(handle, string)
Description
Section titled âDescriptionâThe GetVar Lua function returns the value of a specific variable in a set of variables. To learn more about the variables in plugins, look at the Variable Functions topic.
Arguments
Section titled âArgumentsâ- Handle:
The handle of variable set. - String:
The name of the variable. It needs to be in quotation marks.
- Value:
This is the value of the variable.
If the variable does not exist, then nil is returned.
Example
Section titled âExampleâThis example returns the value of a variable called âmyUserVarâ in the set of user variables if it exists:
| Copy CodeLua |
| ``` |
| return function() |
-- Get the value from a user variable called "myUserVar" - assuming it already existslocal varValue = GetVar(UserVars(), "myUserVar")-- Print en error feedback or the value of the variableif varValue == nil then Printf("Variable returns nothing!")else Printf("Variable value is: " .. varValue)endend