EigeenLoader/utils/Keypad.lua

41 lines
1018 B
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 猫猫虫的 LuaEngine 工具模块Keypad
-- @version: 1.0.0
local Keypad = {}
--- 带计时器的按键触发操作(注:暂不支持组合键)
---@param keypadID number|string
---@param chrono number
---@param func fun()
---@param xbox boolean|nil
function Keypad.UseChronoscope(keypadID, chrono, func, xbox)
if keypadID == nil or chrono == nil or func == nil then
return
end
if chrono < 0 then
return
end
if type(xbox) ~= "boolean" then
xbox = nil
end
-- TODO: 暂不支持组合键
if type(keypadID) == "table" then
return
end
local keypadIDStr = keypadID
if type(keypadID) == "number" then
keypadIDStr = tostring(keypadID)
end
local keypadShortcut = "keypad_keyCD_"..keypadIDStr
if engine.keypad(keypadID, xbox) and (CheckChronoscope(keypadShortcut) or
not CheckPresenceChronoscope(keypadShortcut)) then
AddChronoscope(chrono, keypadShortcut)
func()
end
end
return Keypad