[Home] [Downloads] [Search] [Help/forum]

MUSHclient scripting

Description of MUSHclient world function: world.GetVariableList

Name GetVariableList
Type Method
Summary Gets the list of variables
Prototype VARIANT GetVariableList();

View list of data type meanings


Returns an array of all the variables currently defined.

VBscript example
dim varList

varList = world.GetVariableList

If Not IsEmpty (varList) Then
  For Each v In varList 
    world.note v & " = " &  world.GetVariable (v)

End If
Jscript example
variablelist = new VBArray(world.GetVariableList()).toArray();

if (variablelist)  // if not empty
 for (i = 0; i < variablelist.length; i++)
   world.note(variablelist [i] + " = " + 
       world.GetVariable(variablelist [i]));
PerlScript example
foreach $item (Win32::OLE::in ($world->GetVariableList))
 ($key, $value) = ($item, $world->GetVariable ($item));
 $world->note($key . " = " . $value) if (defined ($key));
Python example
variablelist = world.GetVariableList
if (variablelist ):
  for v in variablelist : world.Note (v + " = " +
Lua example
-- show all variables and their values

for k, v in pairs (GetVariableList()) do 
  Note (k, " = ", v) 
Lua notes
Under Lua this function returns a table of all variables and their values, 
keyed by the variable name.

Thus you can directly access variables from the table, like this:

-- show value for variable "victim" ...

print (GetVariableList ().victim)
Returns If there are no variables then the return value is empty. Use "IsEmpty" to test for this possibility.
Otherwise, it returns a variant array containing the names of all the variables. Use "lbound" and "ubound" to find the bounds of the array of variables (ie. the number of variables in the list). You can then use "GetVariable" to find the contents of each variable.

See also ...

Function Description
GetVariable Gets the contents of a variable
SetVariable Sets the value of a variable

Search for script function

Enter a word or phrase in the box below to narrow the list down to those that match.

The function name, prototype, summary, and description are searched.

Search for:   

Leave blank to show all functions.

Return codes

Many functions return a "code" which indicates the success or otherwise of the function.

You can view a list of the return codes

Function prototypes

The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).

You can view a list of the data types used in function prototypes

View all functions


Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]