From 8348dd2a36426c6e38b35975c34b8735cb4e827d Mon Sep 17 00:00:00 2001 From: Eigeen Date: Thu, 28 Dec 2023 22:42:34 +0800 Subject: [PATCH] =?UTF-8?q?1.0.6=20=E6=94=AF=E6=8C=81=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=83=AD=E9=87=8D=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Changelogs.md | 31 +++++++++++++++++++++++++++++++ README.md | 4 +++- utils/Keypad.lua | 30 +++++++++++++----------------- utils/Utils.lua | 12 ++++++++++++ 4 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 Changelogs.md create mode 100644 utils/Utils.lua diff --git a/Changelogs.md b/Changelogs.md new file mode 100644 index 0000000..2714dcf --- /dev/null +++ b/Changelogs.md @@ -0,0 +1,31 @@ +# 更新日志 + +## 1.0.6 + +**Loader** + +同时按左右花括号键可热重载所有模块 + +**Keypad** + +支持传入 table 类型以实现组合键判断 + +**新增** + +引入 utils/Utils.lua 通用工具类 + +## 1.0.4 + +**新增** + +引入 utils/Macro.lua 宏工具包,支持 Macro 定义简单宏功能进行循环控制 + +## 1.0.3 + +**修订** + +Ctx 在 Loader 中进行全局变量化以减少潜在的 nil 引用问题 + +## 1.0.2 + +首次上传框架 \ No newline at end of file diff --git a/README.md b/README.md index d6d046e..8aeb9af 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # EigeenLoader -猫猫虫的 LuaEngine 插件管理框架 for MHW \ No newline at end of file +猫猫虫的 LuaEngine 插件管理框架 for MHW + +[更新日志](Changelogs.md) \ No newline at end of file diff --git a/utils/Keypad.lua b/utils/Keypad.lua index f039a0d..74903ca 100644 --- a/utils/Keypad.lua +++ b/utils/Keypad.lua @@ -1,15 +1,14 @@ -- 猫猫虫的 LuaEngine 工具模块:Keypad --- @version: 1.0.0 - +-- @version: 1.0.1 local Keypad = {} ---- 带计时器的按键触发操作(注:暂不支持组合键) ----@param keypadID number|string +--- 带计时器的按键触发操作 +---@param keypadID number|string|table ---@param chrono number ----@param func fun() +---@param handler fun() ---@param xbox boolean|nil -function Keypad.UseChronoscope(keypadID, chrono, func, xbox) - if keypadID == nil or chrono == nil or func == nil then +function Keypad.UseChronoscope(keypadID, chrono, handler, xbox) + if not keypadID or not chrono or not handler then return end if chrono < 0 then @@ -19,23 +18,20 @@ function Keypad.UseChronoscope(keypadID, chrono, func, xbox) xbox = nil end - -- TODO: 暂不支持组合键 - if type(keypadID) == "table" then - return - end - local keypadIDStr = keypadID if type(keypadID) == "number" then keypadIDStr = tostring(keypadID) + elseif type(keypadID) == "table" then + keypadIDStr = table.concat(keypadID, ",") end - local keypadShortcut = "keypad_keyCD_"..keypadIDStr + local keypadShortcut = "keypad_keyCD_" .. keypadIDStr - if engine.keypad(keypadID, xbox) and (CheckChronoscope(keypadShortcut) or - not CheckPresenceChronoscope(keypadShortcut)) then + if engine.keypad(keypadID, xbox) and + (CheckChronoscope(keypadShortcut) or not CheckPresenceChronoscope(keypadShortcut)) then AddChronoscope(chrono, keypadShortcut) - func() + handler() end end -return Keypad \ No newline at end of file +return Keypad diff --git a/utils/Utils.lua b/utils/Utils.lua new file mode 100644 index 0000000..43c2d1f --- /dev/null +++ b/utils/Utils.lua @@ -0,0 +1,12 @@ +local Utils = {} + +function Utils:IsIn(table, element) + for key, value in pairs(table) do + if element == value then + return true + end + end + return false +end + +return Utils