




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、天龙八部服务器端lua脚本系统(Tianlong eight server Lua script system)Tianlong eight server Lua script system2010-09-07 14:24 reading (1916) comments (0)I. Lua script function interface1. LuaInterface.h/.cpp declaration and implementation of LuaInterface.LuaInterface members are as follows:/ / script engineFoxLua
2、Script mLua;/ / registerLuaCFuncRegister mFuncRegister;/ / scenariosScene* mOwner;/ / already read the script tableIDTable m_ScriptTable;Main method:VOID Init (Scene* pScene); / / export complete initialization and C function Lua scripting environment for the registrationScene*, GetOwner ();Execute
3、the C+ interface of the Lua script, providing up to 8 parameter support.INT ExeScript (ScriptID_t, scriptid, CHAR*, funcname);INT ExeScript_D (ScriptID_t, scriptid, CHAR*, funcname, INT, Param0);INT, ExeScript_DD (ScriptID_t, scriptid, CHAR*, funcname, INT, Param0, INT, Param1);INT, ExeScript_DDD (S
4、criptID_t, scriptid, CHAR*, funcname, INT, Param0, INT, Param1, INT, Param2);INT, ExeScript_DDDD (ScriptID_t, scriptid, CHAR*, funcname, INT, Param0, INT, Param1, INT, Param2, INT, Param3);LuaInterface: the Init initializes the mLua engine, registers the C+, provides the Lua script function (LuaCFun
5、cRegister), and loads the ScriptGlobal.lua script.In 2., Lua registers all the C+ functions exported to LuaCFuncRegister.cpp.Struct, _Str2Func, functbl ="AddEventList", FuncProto (LuaFnAddNumText),"GetMission", FuncProto (LuaFnGetMission),"GetMissionCount", FuncProto (L
6、uaFnGetMissionCount),"SetMissionByIndex", FuncProto (LuaFnSetMissionByIndex),"AddMission", FuncProto (LuaFnAddMission),"AddMissionEx", FuncProto (LuaFnAddMissionEx),"SetMissionEvent", FuncProto (LuaFnSetMissionEvent),.;The implementation of these C+ functions
7、is done in the following header files:#include "LuaFnTbl_Mission.h""#include "LuaFnTbl_Misc.h""#include "LuaFnTbl_Ability.h""#include "LuaFnTbl_Attr.h""#include "LuaFnTbl_Pet.h""#include "LuaFnTbl_Battle.h""#in
8、clude "LuaFnTbl_Shop.h""#include "LuaFnTbl_PetPlacard.h""#include "LuaFnTbl_Scene.h""#include "LuaFnTbl_Team.h""#include "LuaFnTbl_DoAction.h""#include "LuaFnTbl_Relation.h""#include "LuaFnTbl_Guild.h"
9、;"#include "LuaFnTbl_City.h""These functions are not really where the functions are implemented, and the real implementation code is in places like Scene, Obj_Human, and so forth. Here is the only focus.3. after registration is completed, you can use the AddMission interface to i
10、nvoke the C+ functionality inside the Lua script.Two, Lua script locationAll scripts are in the BinPublicDataScript subdirectory.BinPublicDataScript.dat is the index, which contains the ScriptID and the corresponding script file name. Such as:888888=scene.lua888889=mail.lua888890=player_login.lua.Th
11、e script ID is 6 bit.Three, initialization of the script indexEach scene initializes the script, specifically in Scene: Load,After initialization of m_pLuaInterface.M_pLuaInterface->Init (this);If (. M_pScriptFileMgr->IsInit ()M_pScriptFileMgr->Init (FILE_SCRIPT, FALSE);Log: SaveLog (SERVER
12、_LOGFILE, Load,./Public/Data/script.dat, OK,.);M_pScriptFileMgr->Init opens the 888888=scene.lua and saves the ID and file names inside the SFileData. All SFileData strings are strung together in SFileDataLink.Four script loading and callingEach script is invoked by means of INT LuaFnCallScriptFu
13、nction (Lua_State* L). The function is a C+ function, and the call inside the script is CallScriptFunction, registered as follows:"CallScriptFunction", FuncProto (LuaFnCallScriptFunction),The implementation of LuaFnCallScriptFunction is in file LuaFnTbl_Misc.h.As you can see, this function
14、:L adds SFileData to the pScene->GetLuaInterface () ->m_ScriptTable table;PSFileData = pScene->GetLuaInterface (), ->GetOwner (), ->GetScriptFileMgr (), ->GetFileData (scriptId);PScene->GetLuaInterface () ->m_ScriptTable.Add (scriptId, pSFileData);L and then load the script;P
15、Scene->GetLuaInterface () ->mLua.Load (const_cast<CHAR*> (filename);L finally calls the script.Five, the structure of a typical scriptSee ScriptDef.h, which defines some scripting interface functions, such as OnDefaultEvent, for script 805007, that is:Function, x805007_OnDefaultEvent (sc
16、eneId, selfId, targetId);Some calls do not define macros here. They are written directly in the C+ code, such as OnScenePlayerLogin.#define DEF_EVENT_ENTRY_FUNC_NAME ("OnDefaultEvent") / script into function#define DEF_ON_KILL_OBJECT_FUNC_NAME ("OnKillObject")#define DEF_ON_ITEM_
17、CHANGED_FUNC_NAME ("OnItemChanged")#define DEF_ON_PET_CHANGED_FUNC_NAME ("OnPetChanged")#define DEF_ON_ENTER_AREA_FUNC_NAME ("OnEnterArea")#define DEF_ON_LEAVE_AREA_FUNC_NAME ("OnLeaveArea")#define DEF_EVENT_ON_TIMER ("OnTimer")#define DEF_MISSION_AC
18、CEPT ("OnMissionAccept") / / accept the task#define DEF_MISSION_ABANDON ("OnAbandon") / / give up the task#define DEF_MISSION_REFUSE ("OnMissionRefuse") / refused to accept the task#define DEF_MISSION_SUBMIT ("OnMissionSubmit") / / after the completion of the
19、task, task#define DEF_MISSION_CHECK ("OnMissionCheck") / / task completion condition check#define DEF_MISSION_CONTINUE ("OnMissionContinue") / / did not complete the task, continue toSix, sample analysisDali NPC Zhao Tianshi script analysisScript name: Scriptobjdaliodali_xinshout
20、ian.lua, Khan, actually called this name, looking for a long time, the general name is pinyin.- Zhao Tianshi- script numberX002030_g_scriptId = 002030- the list of events that have IDX002030_g_eventList=210200210204210205210208210210210212210213210214210216210217210220210223, 210224, 210225, 210229, 210230, 210232, 210238, 210239, 210237, 210240, 200080, 20
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年布制家居日用品行业深度研究报告
- 合同执行监督
- 《2022世界卫生统计报告》翻译实践报告
- 离子液体分离氢氟烃与氢氟烯烃的分子模拟与实验研究
- 简易版代理记账合同
- 视频拍摄合同
- 2025-2030年全球及中国带数字显示的房间恒温器行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030年全球及中国冬季游泳池盖行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030年中国集成水槽行业市场现状供需分析及投资评估规划分析研究报告
- 装饰装修工程施工合同
- 舞台剧合作合同协议
- 影视文化试题及答案解析
- 施工现场安全施工方案
- DB63T2004-2021 沥青路面就地冷再生基层技术规范
- 华为结构面试题及答案
- 大学武术知到智慧树章节测试课后答案2024年秋浙江大学
- 2023年全国职业院校技能大赛-老年护理与保健赛项规程
- MOOC 财政学-浙江财经大学 中国大学慕课答案
- JJG 443-2023燃油加油机(试行)
- 材料力学第4版单辉祖习题答案
- 消防控制室值班记录1
评论
0/150
提交评论