天龙八部服务器端lua脚本系统(Tianlong eight server Lua script system)

  发布时间:2024-05-01 11:06:27   作者:玩站小弟   我要评论
1、天龙八部服务器端lua脚本系统Tianlong eight server Lua script system)Tianlong eight server Lua script system2010 。

天龙八部服务器端lua脚本系统(Tianlong eight server Lua script system)

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""The部服se 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,https://www.renrendoc.com/paper/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

  • Tag:

相关文章

  • 魔兽世界WOW勇气试炼开启时间 勇气试炼攻略指南

    魔兽世界勇气试炼怎么开启 魔兽世界勇气试炼解析。魔兽世界勇气试炼什么时候解锁?对于即将开启的团队副本勇气试炼大家是不是都很期待呢?那么魔兽世界勇气试炼位置在哪里呢?下面小编为大家详细介绍。魔兽世界勇气
    2024-05-01
  • 摘抄优美句子高中(摘抄优美句子高中生作文)

    摘抄优美句子是一种培养审美情趣和语言表达能力的重要方法。在高中阶段,摘抄优美句子对于学生的写作和阅读能力的提升有着重要的意义。本文将从不同角度探讨摘抄优美句子在高中阶段的应用和作用。1. 培养阅读兴趣
    2024-05-01
  • 表示读书的名言名句(表示读书的名言名句有哪些)

    读书是人类进步的阶梯,是智慧的源泉。从古至今,无数伟人、思想家、文学家都为读书赋予了深刻的意义,留下了许多令人心潮澎湃的名言名句。这些名言名句用简洁的语言传达了读书的价值和重要性,激励着人们不断追求知
    2024-05-01
  • 有关父母爱的名言(有关父母爱的名言警句有哪些)

    父母爱是世界上最伟大、最无私的爱。他们为子女付出一切,无论是物质上的支持还是情感上的关怀,都是源源不断地传递着父母的爱。父母的爱是无限的,就像大海一样广阔深沉,无论我们走到何处,都能感受到他们的温暖和
    2024-05-01
  • 十句关于父爱的名言(十句关于读书的名言短句)

    父爱是世界上最伟大、最无私的情感之一。它展现了父亲对子女的关爱、奉献和保护,是一种无言的力量,也是一种永不停息的牵挂。在这篇文章中,我将为大家介绍十句关于父爱的名言,并通过分段落的方式展示这些名言在不
    2024-05-01

最新评论