Components

C++
To make a component in C++, you need to inherit from the Component class. You must include a function called "Clone" (look at the example) that returns a new copy constructed component. Also, you need to include the macro "COMPONENT_REGISTER" during the Meta Registration. Here is an example: class   Transform   :   public   Component {    public : Math :: Point3D   GetPosition   const ; void   SetPosition ( const   Math :: Point3D   & pos ); Math :: Vector3D   GetScale   const ; void   SetScale ( const   Math :: Vector3D   & scale ); Math :: Vector3D   GetRotation   const ; void   SetRotation ( const   Math :: Vector3D   & rotation ); virtual   Component   * Clone   const ; private : Math :: Point3D   m_Position ; Math :: Vector3D   m_Scale ; Math :: Vector3D   m_Rotation ; CLASS_START ( Transform ) DERIVE ( Component ); PROPERTY ( "Position",   GetPosition ,   SetPosition ). SERIALIZE. SCRIPT ; PROPERTY ( "Scale",   GetScale ,   SetScale ). SERIALIZE. SCRIPT ; PROPERTY ( "Rotation",   GetRotation ,   SetRotation ). SERIALIZE. SCRIPT ; COMPONENT_REGISTER ; BIND_LUA ; CLASS_END };

Scripting
Script Components should only be used in the case of scripts and aren't meant to work well with C++ code. If you are trying to get a script component in C++ and access variables, that is going to a pain. It will be better to reimplement the component in C++.

In the folder "Data\LuaScripts\Components", create a text file (with extension ".lua") and name it the name of the component. Inside of the file is where you will add the different variables of the component and do the scripting for the component. The format for variables is: --! DataType VariableName Value The part with the "--[ [!" and the "] ]" is required at the top of the file so when parsing the file, we know where to look for these variables. These values will then be allowed to be serailized and used in the editor. DataType must be a type registered with the Meta System. You must specify a value for the variable so that the variable has a default value.

Here is an example of a component: --! string SomeString "Default" Vector3D SomeVec { 1 2 3 }

Using Components in Scripts
For all components, you are able to access them like any member or property in Lua. For example we can access the Transform component like this: transform = owner.Transform; We are also able to access different members methods of components that are registered in C++: owner.ExampleComponent:CallAMethod; owner.ExampleComponent.Member = 5; variable = owner.ExampleComponent.Member; For functions in a script that belong to a component, we are also able to call those functions too. If this script here was attached to "ExampleScriptComponent": function Initialize end function TestFunction(vec, someString) print("TestFunction called!"); print(someString); print(vec.x); return 5; end You could call the function like any other function/method for a component: owner.ExampleScriptComponent:TestFunction(Vector2D(1, 2), "A string");