> > |
%META:TOPICINFO{author="ElminI" date="1075413698" format="1.0" version="1.1"}%
%META:TOPICPARENT{name="MakingZippyObjects"}%
Namespaces are collections of fields where each collection is associated with a global variable. Namespaces may be defined with the following syntax:
Namespace{ "namespace_name";
field = value,
}
Where "field," "value," and "namespace_name" may be replaced with the named quantities.
The fields will thereafter be available as members of the namespace as follows:
namespace_name.field
Namespaces may additionally contain placeholders indicating that the value for a field may be obtained by loading another file. These take the following form:
Namespace{ "name";
external_field = in_file("path/to/file.lua"),
}
These fields will not be accessible until they are "required;" this may be indicated with the "Require" function:
Require(name.external_field)
If a file must be loaded to obtain the value for a required field, it will be loaded during the call to "Require."
Certain functions (for example, ActionClass and register_type) will allow a namespace to be specified as a field of the argument table:
register_type{
name = "CharacterClass",
namespace = Basic,
-- ...
}
This will add the field "CharacterClass" in the already-declared namespace "Basic" with the value being the class itself.
-- ElminI - 29 Jan 2004 |