x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
ScriptEngine.cpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\DarkPuzzle\GameEngine\ScriptEngine.cpp
旋转
特效
属性
历史版本
//#include "DXUT.h" #include "DarkPuzzle.h" #include "ScriptEngine.h" TOLUA_API int tolua_dp_scripts_open (lua_State* tolua_S); namespace DarkBattle{ #define SCRIPT_FUNC_SETCONSTANT "SetConstants" #define SCRIPT_FUNC_INITIALIZE "Initialize" #define LUA_FILE_FUNCTIONS "resources\\scripts\\functions.lua" extern FILE* fdebug; //ScriptEngine* theScriptEngine; ScriptEngine* ScriptEngine::theScriptEngine = NULL; void ScriptEngine::report_errors(lua_State *L, int status) { if ( status!=0 ) { DEBUG_OUTPUT("%s\n",lua_tostring(L, -1)); lua_pop(L, 1); // remove error message } } ScriptEngine::ScriptEngine(){ L = lua_open(); //luaopen_io(L); // provides io.* luaopen_base(L); luaopen_table(L); luaopen_string(L); luaopen_math(L); //luaopen_loadlib(L); tolua_open(L); tolua_dp_scripts_open(L); ScriptEngine::theScriptEngine = this; } ScriptEngine::~ScriptEngine(){ lua_close(L); ScriptEngine::theScriptEngine = NULL; } void ScriptEngine::ReLoadConstants(){ int s = luaL_dofile(L, LUA_FILE_FUNCTIONS); //assert(s==0);//load successfully // execute Lua function setting constants executeFunction(SCRIPT_FUNC_SETCONSTANT); //DEBUG_OUTPUT("Setting constants completed.\n"); } void ScriptEngine::Initialize(){ //int s = luaL_dofile(L, file); //assert(s==0);//load successfully // execute Lua function setting constants executeFunction(SCRIPT_FUNC_INITIALIZE); //DEBUG_OUTPUT("Initiali completed.\n"); } void ScriptEngine::ExecuteString(const char* str){ DEBUG_OUTPUT("Executing \"%s\":\n",str); int s = luaL_dostring(L, str); //assert(s==0);//load successfully report_errors(L, s); } void ScriptEngine::executeFunction(const char* funcName){ lua_getglobal(L,funcName); int s = lua_pcall(L, 0, LUA_MULTRET, 0); report_errors(L, s); } void ScriptEngine::ExecuteOneParamFunction(const char* funcName,void* param1, const char* param1Type){ //lua_getglobal(L,param1Type); tolua_pushusertype(L,param1,param1Type); lua_getfield(L,-1,funcName); tolua_pushusertype(L,param1,param1Type); int s = lua_pcall(L, 1, LUA_MULTRET, 0); report_errors(L, s); } void ScriptEngine::ExecuteTwoParamFunction(const char* funcName,void* param1, const char* param1Type, void* param2, const char* param2Type){ //lua_getglobal(L,param1Type); tolua_pushusertype(L,param1,param1Type); lua_getfield(L,-1,funcName); tolua_pushusertype(L,param1,param1Type); tolua_pushusertype(L,param2,param2Type); int s = lua_pcall(L, 2, LUA_MULTRET, 0); report_errors(L, s); } void ScriptEngine::DoFile(const char* fileName){ DEBUG_OUTPUT("Doing file :%s\n",fileName); int s = luaL_dofile(L, fileName); report_errors(L, s); } }
ScriptEngine.cpp
网页地址
文件地址
上一页
58/65
下一页
下载
( 2 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.