Glossary
This glossary will list the most commonly appearing terms used in the guide, what they mean and the effect they have on how you use classes.
Categories
Component parts of classes are categorised into different groups.
Constructors
A constructor is a function with the same name as the class that takes zero or more arguments and returns a new instance of the class.
--Create a new Vector using the Vector constructor
local position = Vector( 1, 2, 3 )
Static Functions
A static function can only be used directly on the class itself - that is, not on an instance. They are class-specfic actions, rather than instance specific and are called using a dot rather than a colon.
--Use the static function "getAll" in the Race class. This will get a collection of all Races
local races = Race.getAll( )
Instance Functions
An instance function can only be called when you have an instance of the class. They are called using a colon.
--Use the instance function normalize on a vector (we create it using the constructor first)
local direction = Vector( 0, 100, 200 )
direction = direction:normalize()
Operators
An operator entry indicates that you can use one of the built in Lua operators with an instance of this class and another instance (of the same or a different class).
--Using a created Vector, we use the * operator to multiply it with a scalar value.
local direction = Vector( 0, 0, 1 )
--This multiplies the vector by 100.
direction = direction * 100
Enumerations
An enumeration is essentially a table of values that represent a set of options that can be used for operations.
--Using an entity we create, we give it some orders using the GameObject.Order enumeration
local ent = Entity.add( "fed_akiraZ.odf", 1, Vector( 1000, 0, 1000 ) )
ent:giveOrder( GameObject.Order.Stop )
ent:giveOrder( GameObject.Order.Scout )
Properties
A property is a value that an instance of class has. Depending on the access rights, you can read (R) or write (W) the value.
--Here we set the teamText property on the global instance of the UI class
UI.teamText = "Testing"
Attribute Tags
Attribute tags appear in italics at the start of class and function pages. They indicate how you should use the class or function they are associated with.
Tag | Description |
---|---|
constructor | See Constructor category |
static function | See Static Function category |
instance function | See Instance Function category |
operator | See Operator category |
global instance | A global instance attribute tag means that you do not (and cannot) call a constructor to create your own instance - there is already an instance created for your use. The global instance has the same name as the class and instance functions can be used as normal with it. |
Inheritance
Some classes inherit other classes. That means that they have all the properties and functions of that class. The GameObject class inherits from Entity - GameObject has all the properties and functions of the Entity class. We can also describe this relationship by saying that GameObject is a derived type of Entity. You can treat an instance of the more specialized class an instance of the base class (GameObject in place of Entity in this example).