cocos2d-x  3.0-rc0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LuaEngine Class Reference

#include <CCLuaEngine.h>

Inheritance diagram for LuaEngine:
ScriptEngineProtocol

Public Member Functions

virtual ~LuaEngine (void)
virtual ccScriptType getScriptType ()
 Get script type. More...
 
LuaStackgetLuaStack (void)
virtual void addSearchPath (const char *path)
 Add a path to find lua files in. More...
 
local addSearchPath ( local path)
 Add a path to find lua files in. More...
 
virtual void addLuaLoader (lua_CFunction func)
 Add lua loader, now it is used on android. More...
 
local addLuaLoader ( local func)
 Add lua loader, now it is used on android. More...
 
virtual int reload (const char *moduleFileName)
 reload script code contained in the given string. More...
 
virtual void removeScriptObjectByObject (Ref *object)
 Remove Object from lua state. More...
 
local removeScriptObjectByObject ( local object)
 Remove Object from lua state. More...
 
virtual void removeScriptHandler (int nHandler)
 Remove Lua function reference. More...
 
local removeScriptHandler ( local nHandler)
 Remove Lua function reference. More...
 
virtual int reallocateScriptHandler (int nHandler)
 Reallocate Lua function reference. More...
 
virtual int executeString (const char *codes)
 Execute script code contained in the given string. More...
 
virtual int executeScriptFile (const char *filename)
 Execute a script file. More...
 
local executeScriptFile ( local filename)
 Execute a script file. More...
 
virtual int executeGlobalFunction (const char *functionName)
 Execute a scripted global function. More...
 
local executeGlobalFunction ( local functionName)
 Execute a scripted global function. More...
 
virtual int executeNodeEvent (Node *pNode, int nAction)
virtual int executeMenuItemEvent (MenuItem *pMenuItem)
virtual int executeNotificationEvent (__NotificationCenter *pNotificationCenter, const char *pszName)
local executeNotificationEvent ( local pNotificationCenter, local pszName)
virtual int executeCallFuncActionEvent (CallFunc *pAction, Ref *pTarget=NULL)
virtual int executeSchedule (int nHandler, float dt, Node *pNode=NULL)
local executeSchedule ( local nHandler, local dt, local NULL)
virtual int executeLayerTouchesEvent (Layer *pLayer, int eventType, __Set *pTouches)
local executeLayerTouchesEvent ( local pLayer, local eventType, local pTouches)
virtual int executeLayerTouchEvent (Layer *pLayer, int eventType, Touch *pTouch)
local executeLayerTouchEvent ( local pLayer, local eventType, local pTouch)
virtual int executeLayerKeypadEvent (Layer *pLayer, int eventType)
virtual int executeAccelerometerEvent (Layer *pLayer, Acceleration *pAccelerationValue)
 execute a accelerometer event More...
 
virtual int executeEvent (int nHandler, const char *pEventName, Ref *pEventSource=NULL, const char *pEventSourceClassName=NULL)
virtual bool handleAssert (const char *msg)
 called by CCAssert to allow scripting engine to handle failed assertions More...
 
virtual bool parseConfig (ConfigType type, const std::string &str) override
 Parse configuration file. More...
 
local parseConfig ( local type, local str)
 Parse configuration file. More...
 
virtual int sendEvent (ScriptEvent *message) override
 when trigger a script event ,call this func,add params needed into ScriptEvent object.nativeObject is object triggering the event, can be nullptr in lua More...
 
local sendEvent ( local message)
 when trigger a script event ,call this func,add params needed into ScriptEvent object.nativeObject is object triggering the event, can be nullptr in lua More...
 
virtual int handleEvent (ScriptHandlerMgr::HandlerType type, void *data)
local handleEvent ( local type, local data)
virtual int handleEvent (ScriptHandlerMgr::HandlerType type, void *data, int numResults, const std::function< void(lua_State *, int)> &func)
local handleEvent ( local type, local data, local numResults, local func)
- Public Member Functions inherited from ScriptEngineProtocol
 ScriptEngineProtocol ()
virtual ~ScriptEngineProtocol ()
virtual void setCalledFromScript (bool callFromScript)
virtual bool isCalledFromScript ()

Static Public Member Functions

static LuaEnginegetInstance (void)
local getInstance ()
static CC_DEPRECATED_ATTRIBUTE
LuaEngine
defaultEngine (void)
local defaultEngine ()

Additional Inherited Members

- Public Types inherited from ScriptEngineProtocol
enum  ConfigType { NONE, COCOSTUDIO }
 

Constructor & Destructor Documentation

virtual ~LuaEngine ( void  )
virtual
var ~LuaEngine (   )
virtual
local ~LuaEngine (   )
virtual

Member Function Documentation

virtual void addLuaLoader ( lua_CFunction  func)
virtual

Add lua loader, now it is used on android.

var addLuaLoader ( var  func)
virtual

Add lua loader, now it is used on android.

local addLuaLoader ( local  func)
virtual

Add lua loader, now it is used on android.

virtual void addSearchPath ( const char *  path)
virtual

Add a path to find lua files in.

Parameters
pathto be added to the Lua path
var addSearchPath ( var  path)
virtual

Add a path to find lua files in.

Parameters
pathto be added to the Lua path
local addSearchPath ( local  path)
virtual

Add a path to find lua files in.

Parameters
pathto be added to the Lua path
static CC_DEPRECATED_ATTRIBUTE
LuaEngine* defaultEngine
( void  )
inlinestatic
var defaultEngine (   )
inlinestatic
local defaultEngine (   )
inlinestatic
virtual int
executeAccelerometerEvent
( Layer pLayer,
Acceleration pAccelerationValue 
)
virtual

execute a accelerometer event

var executeAccelerometerEvent ( var  pLayer,
var  pAccelerationValue 
)
virtual

execute a accelerometer event

local executeAccelerometerEvent ( local  pLayer,
local  pAccelerationValue 
)
virtual

execute a accelerometer event

virtual int
executeCallFuncActionEvent
( CallFunc pAction,
Ref pTarget = NULL 
)
virtual
var executeCallFuncActionEvent ( var  pAction,
var  pTarget = NULL 
)
virtual
local executeCallFuncActionEvent ( local  pAction,
local  pTarget = NULL 
)
virtual
virtual int executeEvent ( int  nHandler,
const char *  pEventName,
Ref pEventSource = NULL,
const char *  pEventSourceClassName = NULL 
)
virtual
var executeEvent ( var  nHandler,
var  pEventName,
var  pEventSource = NULL,
var  pEventSourceClassName = NULL 
)
virtual
local executeEvent ( local  nHandler,
local  pEventName,
local  pEventSource = NULL,
local  pEventSourceClassName = NULL 
)
virtual
virtual int executeGlobalFunction ( const char *  functionName)
virtual

Execute a scripted global function.

The function should not take any parameters and should return an integer.

Parameters
functionNameString object holding the name of the function, in the global script environment, that is to be executed.
Returns
The integer value returned from the script function.

Implements ScriptEngineProtocol.

var executeGlobalFunction ( var  functionName)
virtual

Execute a scripted global function.

The function should not take any parameters and should return an integer.

Parameters
functionNameString object holding the name of the function, in the global script environment, that is to be executed.
Returns
The integer value returned from the script function.

Implements ScriptEngineProtocol.

local executeGlobalFunction ( local  functionName)
virtual

Execute a scripted global function.

The function should not take any parameters and should return an integer.

Parameters
functionNameString object holding the name of the function, in the global script environment, that is to be executed.
Returns
The integer value returned from the script function.

Implements ScriptEngineProtocol.

virtual int executeLayerKeypadEvent ( Layer pLayer,
int  eventType 
)
virtual
var executeLayerKeypadEvent ( var  pLayer,
var  eventType 
)
virtual
local executeLayerKeypadEvent ( local  pLayer,
local  eventType 
)
virtual
virtual int
executeLayerTouchesEvent
( Layer pLayer,
int  eventType,
__Set pTouches 
)
virtual
var executeLayerTouchesEvent ( var  pLayer,
var  eventType,
var  pTouches 
)
virtual
local executeLayerTouchesEvent ( local  pLayer,
local  eventType,
local  pTouches 
)
virtual
virtual int executeLayerTouchEvent ( Layer pLayer,
int  eventType,
Touch pTouch 
)
virtual
var executeLayerTouchEvent ( var  pLayer,
var  eventType,
var  pTouch 
)
virtual
local executeLayerTouchEvent ( local  pLayer,
local  eventType,
local  pTouch 
)
virtual
virtual int executeMenuItemEvent ( MenuItem pMenuItem)
virtual
var executeMenuItemEvent ( var  pMenuItem)
virtual
local executeMenuItemEvent ( local  pMenuItem)
virtual
virtual int executeNodeEvent ( Node pNode,
int  nAction 
)
virtual
var executeNodeEvent ( var  pNode,
var  nAction 
)
virtual
local executeNodeEvent ( local  pNode,
local  nAction 
)
virtual
virtual int
executeNotificationEvent
( __NotificationCenter pNotificationCenter,
const char *  pszName 
)
virtual
var executeNotificationEvent ( var  pNotificationCenter,
var  pszName 
)
virtual
local executeNotificationEvent ( local  pNotificationCenter,
local  pszName 
)
virtual
virtual int executeSchedule ( int  nHandler,
float  dt,
Node pNode = NULL 
)
virtual
var executeSchedule ( var  nHandler,
var  dt,
var  pNode = NULL 
)
virtual
local executeSchedule ( local  nHandler,
local  dt,
local  pNode = NULL 
)
virtual
virtual int executeScriptFile ( const char *  filename)
virtual

Execute a script file.

Parameters
filenameString object holding the filename of the script file that is to be executed

Implements ScriptEngineProtocol.

var executeScriptFile ( var  filename)
virtual

Execute a script file.

Parameters
filenameString object holding the filename of the script file that is to be executed

Implements ScriptEngineProtocol.

local executeScriptFile ( local  filename)
virtual

Execute a script file.

Parameters
filenameString object holding the filename of the script file that is to be executed

Implements ScriptEngineProtocol.

virtual int executeString ( const char *  codes)
virtual

Execute script code contained in the given string.

Parameters
codesholding the valid script code that should be executed.
Returns
0 if the string is excuted correctly.
other if the string is excuted wrongly.

Implements ScriptEngineProtocol.

var executeString ( var  codes)
virtual

Execute script code contained in the given string.

Parameters
codesholding the valid script code that should be executed.
Returns
0 if the string is excuted correctly.
other if the string is excuted wrongly.

Implements ScriptEngineProtocol.

local executeString ( local  codes)
virtual

Execute script code contained in the given string.

Parameters
codesholding the valid script code that should be executed.
Returns
0 if the string is excuted correctly.
other if the string is excuted wrongly.

Implements ScriptEngineProtocol.

static LuaEngine* getInstance ( void  )
static
var getInstance (   )
static
local getInstance (   )
static
LuaStack* getLuaStack ( void  )
inline
var getLuaStack (   )
inline
local getLuaStack (   )
inline
virtual ccScriptType getScriptType ( )
inlinevirtual

Get script type.

Reimplemented from ScriptEngineProtocol.

var getScriptType ( )
inlinevirtual

Get script type.

Reimplemented from ScriptEngineProtocol.

local getScriptType ( )
inlinevirtual

Get script type.

Reimplemented from ScriptEngineProtocol.

virtual bool handleAssert ( const char *  msg)
virtual

called by CCAssert to allow scripting engine to handle failed assertions

Returns
true if the assert was handled by the script engine, false otherwise.

Implements ScriptEngineProtocol.

var handleAssert ( var  msg)
virtual

called by CCAssert to allow scripting engine to handle failed assertions

Returns
true if the assert was handled by the script engine, false otherwise.

Implements ScriptEngineProtocol.

local handleAssert ( local  msg)
virtual

called by CCAssert to allow scripting engine to handle failed assertions

Returns
true if the assert was handled by the script engine, false otherwise.

Implements ScriptEngineProtocol.

virtual int handleEvent ( ScriptHandlerMgr::HandlerType  type,
void *  data 
)
virtual
var handleEvent ( var  type,
var  data 
)
virtual
local handleEvent ( local  type,
local  data 
)
virtual
virtual int handleEvent ( ScriptHandlerMgr::HandlerType  type,
void *  data,
int  numResults,
const std::function< void(lua_State *, int)> &  func 
)
virtual
var handleEvent ( var  type,
var  data,
var  numResults,
var  func 
)
virtual
local handleEvent ( local  type,
local  data,
local  numResults,
local  func 
)
virtual
virtual bool parseConfig ( ConfigType  type,
const std::string &  str 
)
overridevirtual

Parse configuration file.

Implements ScriptEngineProtocol.

var parseConfig ( var  type,
var  str 
)
overridevirtual

Parse configuration file.

Implements ScriptEngineProtocol.

local parseConfig ( local  type,
local  str 
)
overridevirtual

Parse configuration file.

Implements ScriptEngineProtocol.

virtual int reallocateScriptHandler ( int  nHandler)
virtual

Reallocate Lua function reference.

Reimplemented from ScriptEngineProtocol.

var reallocateScriptHandler ( var  nHandler)
virtual

Reallocate Lua function reference.

Reimplemented from ScriptEngineProtocol.

local reallocateScriptHandler ( local  nHandler)
virtual

Reallocate Lua function reference.

Reimplemented from ScriptEngineProtocol.

virtual int reload ( const char *  moduleFileName)
virtual

reload script code contained in the given string.

Parameters
moduleFileNameString object holding the filename of the script file that is to be executed
Returns
0 if the string is excuted correctly.
other if the string is excuted wrongly.
var reload ( var  moduleFileName)
virtual

reload script code contained in the given string.

Parameters
moduleFileNameString object holding the filename of the script file that is to be executed
Returns
0 if the string is excuted correctly.
other if the string is excuted wrongly.
local reload ( local  moduleFileName)
virtual

reload script code contained in the given string.

Parameters
moduleFileNameString object holding the filename of the script file that is to be executed
Returns
0 if the string is excuted correctly.
other if the string is excuted wrongly.
virtual void removeScriptHandler ( int  nHandler)
virtual

Remove Lua function reference.

Reimplemented from ScriptEngineProtocol.

var removeScriptHandler ( var  nHandler)
virtual

Remove Lua function reference.

Reimplemented from ScriptEngineProtocol.

local removeScriptHandler ( local  nHandler)
virtual

Remove Lua function reference.

Reimplemented from ScriptEngineProtocol.

virtual void
removeScriptObjectByObject
( Ref object)
virtual

Remove Object from lua state.

Parameters
objectto remove

Implements ScriptEngineProtocol.

var removeScriptObjectByObject ( var  object)
virtual

Remove Object from lua state.

Parameters
objectto remove

Implements ScriptEngineProtocol.

local removeScriptObjectByObject ( local  object)
virtual

Remove Object from lua state.

Parameters
objectto remove

Implements ScriptEngineProtocol.

virtual int sendEvent ( ScriptEvent evt)
overridevirtual

when trigger a script event ,call this func,add params needed into ScriptEvent object.nativeObject is object triggering the event, can be nullptr in lua

Implements ScriptEngineProtocol.

var sendEvent ( var  evt)
overridevirtual

when trigger a script event ,call this func,add params needed into ScriptEvent object.nativeObject is object triggering the event, can be nullptr in lua

Implements ScriptEngineProtocol.

local sendEvent ( local  evt)
overridevirtual

when trigger a script event ,call this func,add params needed into ScriptEvent object.nativeObject is object triggering the event, can be nullptr in lua

Implements ScriptEngineProtocol.


The documentation for this class was generated from the following file: