你好,
我终于回到了新版的Warcraft Lua Engine。
那么,有什么变化?
以完整的新方式重新编写引擎,从而提高性能 现在我们支持每一个jass本地人!没有你不能打电话的本地的。 你可以在他们被调用之前钩住你想要的每一个jess native,一旦调用它们,就可以改变本机参数和返回值! 添加了功能以获取其他加载的插件的句柄,以便您可以卸载它们,或者获取他们的名称和他们的作者姓名。 增加了LuaSocket的支持。 添加了一个插件编写器可以用来编译插件的工具(没有必要编译一个插件,但是我们给出这个工具,以防有人想在发布之前保护他们的代码。) (本文来源于图老师网站,更多请访问http://m.tulaoshi.com)以及我们将讨论的许多新功能
现在每个插件都应该有一个名为“初始化”的函数,这样游戏一打开就可以调用它。 “初始化”函数有1个参数,这是当前插件的句柄。 见下面的样本:
function Initialize(plugin)
plugin:SetName("Test Plugin")
plugin:SetVersion("1.0")
plugin:SetAuthor("Shahriyar")
plugin:SetDescription("Lua Engine Test Plugin")
plugin:RegisterGameEvent(EVENT.GAME_STARTED, "OnGameStarted")
end
复制代码 (本文来源于图老师网站,更多请访问http://m.tulaoshi.com) 正如你可以看到,我们可以做一些初始化函数中与给定的插件处理。 这里是插件类的全部功能列表:
plugin:RegisterGameEvent(EVENT event, string funcName) -- Events are stated below
plugin:RegisterNativeHook(string native, string funcName_pre, string funcname_post) -- The engine will call the pre function once before the native getting called so you can use or even edit the naive parameters and once after the native got called so you can use the return value and even change it to another value !
plugin:RegisterChatEvent(string chat, string funcName) -- The function will get called when the local user send a chat message containing the string you stated (If the chat matches any event the game won't send the chat message to other clients)
plugin:SetName(string name)
plugin:SetVersion(string version)
plugin:SetAuthor(string author)
plugin:SetDescription(string description)
plugin:GetName()
plugin:GetVersion()
plugin:GetAuthor()
plugin:GetDescription()
plugin:Unload()
复制代码 (本文来源于图老师网站,更多请访问http://m.tulaoshi.com) RegisterNativeHook example:
function MultiboardSetTitleText_Pre(multiboard, text)
local str = jParamStr2cStr(text)
str = "Lua Engine - " .. str
return {multiboard, cStr2jParamStr(str)}
end
function Initialize(plugin)
plugin:SetName("Jass Hooking Test")
plugin:SetVersion("1.0")
plugin:SetAuthor("Shahriyar")
plugin:SetDescription("Lua Engine Sample Plugin")
plugin:RegisterNativeHook("MultiboardSetTitleText", "MultiboardSetTitleText_Pre", "")
end
复制代码 (本文来源于图老师网站,更多请访问http://m.tulaoshi.com)
如果你想改变任何参数,最后你应该返回一个表包含所有参数的正确顺序,如果你不想改变的参数只是返回零,最后。
事件:
EVENT.ENTER_LOBBY
EVENT.ENTER_LOADING
EVENT.GAME_STARTED
EVENT.GAME_PAUSED
EVENT.GAME_RESUMED
EVENT.GAME_FINISHED
EVENT.GAME_TICK -- If you register this event the engine will call the function you given every 100 milliseconds.
EVENT.PLUGIN_UNLOAD -- The engine will call this function as the last function before the plugin unloads
复制代码 (本文来源于图老师网站,更多请访问http://m.tulaoshi.com)如果你想叫JASS本土你不再需要创建一个脚本类和初始化,而不是做为以下方式:
Jass.GetLocalPlayer() -- Simple as that ;)
复制代码 (本文来源于图老师网站,更多请访问http://m.tulaoshi.com)
此外游戏类,在引擎的第一个版本改变了JASS类一样。 例子:
Game.GetMapName()
复制代码 (本文来源于图老师网站,更多请访问http://m.tulaoshi.com)
在游戏命名空间中的函数是一些自定义的函数,我们发现需要添加和这里是列表:
bool Game.IsInGame(bool bPaused) -- If you pass false to this functions the function will return false if you are in game but the game is paused if you pass true the function will return true if you are in game (doesn't matter if the game is paused or not)
void Game.WriteText(string text, FRAME frame, float duration) -- Frames are stated below
void Game.ExecuteCmd(unit Unit, COMMAND cmd, float x, float y, unit target) -- Commands are stated below
string Game.GetMapName()
AbilityState Game.GetAbilityState(unit Unit, integer abilityID) -- Ability states are stated below
bool Game.SendChat(string message, bool bSendToAll, bool bForceMaximizeGame)
复制代码 (本文来源于图老师网站,更多请访问http://m.tulaoshi.com) 框架:
FRAME.MESSAGEFRAME.UNITFRAME.CHATFRANE.TOP
复制代码 (本文来源于图老师网站,更多请访问http://m.tulaoshi.com) 命令:
CMD.MOVECMD.ATTACKCMD.HOLDCMD.STOP您还可以将自定义代码作为整数传递(您可以通过提取地图并从war3map.j读取来获取法术的代码文件)
复制代码 (本文来源于图老师网站,更多请访问http://m.tulaoshi.com)能力状态:
ABILITY_STATE.READYABILITY_STATE.COOLDOWNABILITY_STATE.INVALID
复制代码 (本文来源于图老师网站,更多请访问http://m.tulaoshi.com)还可以使用一些通用功能:
Sleep(integer milliseconds) -- Same as WinAPI Sleep functionGetPlugins() -- Return a table containing handle of all loaded pluginsGetVersion() -- Return the version of the lua engine you're currently using as stringjParamStr2cStr(jParmStr) -- Get a readble string from the jass string handle in native parameters (only usable in hooked native functions)jHandleStr2cStr(jHandleStr) -- Get a readble string from the jass string handle in native return values (only usable in hooked native functions)cStr2jParamStr(cStr) -- Convert an string to jass param string handle (only usable in hooked native functions)GetFloat(jFloat) -- Convert jass floating points handles to readble floating point (only usable in hooked native functions)MakeFloat(float) -- Convert floating point to jass floating point handle (only usable in hooked native functions)
复制代码 (本文来源于图老师网站,更多请访问http://m.tulaoshi.com) |