天龍八部服務(wù)器端lua腳本系統(tǒng)(Tianlong eight server Lua script system)_第1頁(yè)
天龍八部服務(wù)器端lua腳本系統(tǒng)(Tianlong eight server Lua script system)_第2頁(yè)
天龍八部服務(wù)器端lua腳本系統(tǒng)(Tianlong eight server Lua script system)_第3頁(yè)
天龍八部服務(wù)器端lua腳本系統(tǒng)(Tianlong eight server Lua script system)_第4頁(yè)
天龍八部服務(wù)器端lua腳本系統(tǒng)(Tianlong eight server Lua script system)_第5頁(yè)
已閱讀5頁(yè),還剩5頁(yè)未讀 繼續(xù)免費(fèi)閱讀

付費(fèi)下載

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論