1.0.6 支持模块热重载
This commit is contained in:
@@ -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
|
||||
return Keypad
|
||||
|
||||
12
utils/Utils.lua
Normal file
12
utils/Utils.lua
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user