Ryan a2b7565639 Add 'multi/' from commit '285fa7e933d1986bcbd354294c05cee40ef43cea'
git-subtree-dir: multi
git-subtree-mainline: 14f186d8e1f36b38f6816dfa4d004dd023b882ce
git-subtree-split: 285fa7e933d1986bcbd354294c05cee40ef43cea
2017-07-28 11:08:11 -04:00

24 lines
573 B
Plaintext

function gui:setHotKey(key)
local tab=key:split("+")
self.hotkeys=tab
self.cooldown=false
self.Alarm=multi:newAlarm(1)
self.Alarm.parent=self
self.args={}
self.funcHK=multi:newConnection()
self.Alarm:OnRing(function(alarm) alarm.parent.cooldown=false end)
function self:OnHotKey(func)
self.funcHK:connect(func)
end
self:OnUpdate(function(self)
if self.cooldown then return end
for i=1,#self.hotkeys do
if not(love.keyboard.isDown(self.hotkeys[i])) then
return
end
end
self.cooldown=true
self.funcHK:Fire(self)
self.Alarm:Reset()
end)
end