Game Development Reference
In-Depth Information
class BaseScriptComponent : public ScriptComponentInterface
{
std::string m_scriptObjectName;
std::string m_constructorName;
std::string m_destructorName;
LuaPlus::LuaObject m_scriptObject;
LuaPlus::LuaObject m_scriptConstructor;
LuaPlus::LuaObject m_scriptDestructor;
public:
BaseScriptComponent(void);
virtual
BaseScriptComponent(void);
virtual bool VInit(TiXmlElement* pData);
virtual void VPostInit(void);
virtual TiXmlElement* VGenerateXml(void);
˜
static void RegisterScriptFunctions(void);
static void UnregisterScriptFunctions(void);
private:
void CreateScriptObject(void);
// component script functions
LuaPlus::LuaObject GetActorId(void);
// physics component script functions
LuaPlus::LuaObject GetPos(void);
void SetPos(LuaPlus::LuaObject newPos);
LuaPlus::LuaObject GetLookAt(void) const;
float GetYOrientationRadians(void) const;
void RotateY(float angleRadians);
};
The XML definition for this component allows you to define a script object, a con-
structor, and a destructor. The script object is the name of a Lua variable where a Lua
instance of this object will live. The constructor is the name of a Lua function that is
called when the actor has been created, while the destructor is the name of a Lua
function that is called when the actor is destroyed. Both the constructor and destruc-
tor Lua functions are of the form func(scriptObject) , where scriptObject is
the Lua instance of this component.
Since there
m not going to cover it in depth. This class
follows the same basic pattern the others have. The idea behind this class is that it
represents the actor as far as Lua is concerned. All actor-specific functions should
'
s nothing particularly new, I
'
Search WWH ::




Custom Search