Extensions |
The MMFI Object API is a an alternative to the established MMF Interface API built into XLua. Instead of a set of static functions that operate on object IDs, objects exist as their own object table, with their own functions and values. This design is currently experimental and feedback to the developer is welcome.
Each object exists as a special Lua table with fields and functions. These tables are special because they appear empty and functions like pairs and ipairs will return nothing. However these tables track their own fixed IDs and object pointers, and accessing their values allow you to read and change an object's state in MMF directly. Another benefit to these tables is that you can add your own fields and methods like with any other Lua table, and thus keep state and behavior with the object itself.
Object tables are also unique. If you try to get or create a new table for the same object, a reference to the same table will be returned.
Traits
There are several groups of actions/conditions/expressions in MMF that are shared by many different objects in MMF. Examples are movement, visibility, and alterable values. The MMFI can determine at runtime which of these groups, if any, are supported by a particular object, and then expose fields and methods relating to them. You can count on every object at least supporting the common traits, although they may support others. The traits are:
Supported Objects
All objects are supported by the MMFI, by exposing a combination of the traits listed above. There is also additional support for some objects, exposing fields or methods that are specific to a particular type of object. Currently these are:
Third party modules can add specific support for other objects.
Example
Copyright 2010 Justin Aquadro