




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、天龍八部服務(wù)器端lua腳本系統(tǒng)(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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權(quán)】 ISO/IEC 18012-4:2025 EN Information technology - Home electronic system (HES) - Guidelines for product interoperability - Part 4: Event encoding
- 惠州市中考數(shù)學(xué)試卷
- 海泉小升初數(shù)學(xué)試卷
- 河南平輿小升初數(shù)學(xué)試卷
- 醫(yī)院被服管理課件
- 健康管理師配套課件
- 健康管理師總結(jié)課件
- 2025年中國液位顯示儀行業(yè)市場前景預(yù)測及投資價(jià)值評估分析報(bào)告
- 中國劈開式皮帶輪行業(yè)市場調(diào)研分析及投資前景預(yù)測報(bào)告
- 健康社會課件圖片素材
- 統(tǒng)計(jì)技術(shù)應(yīng)用管理辦法
- 水電站安全生產(chǎn)管理制度
- 新版干細(xì)胞培訓(xùn)課件
- 抖音代運(yùn)營公司策劃方案
- 2025至2030洗碗機(jī)里的啤酒行業(yè)產(chǎn)業(yè)運(yùn)行態(tài)勢及投資規(guī)劃深度研究報(bào)告
- 美容培訓(xùn)資料
- 2025年廣西中考英語真題含答案
- 2025年醫(yī)療健康行業(yè)醫(yī)療信息化建設(shè)與網(wǎng)絡(luò)安全研究報(bào)告
- 遼寧省文體旅集團(tuán)所屬企業(yè)招聘筆試題庫2025
- 團(tuán)建活動桌球店活動方案
- 2025屆拉薩市英語七年級第二學(xué)期期中質(zhì)量跟蹤監(jiān)視模擬試題含答案
評論
0/150
提交評論