hotkeys module added

This commit is contained in:
p.kosyh 2010-07-06 09:56:02 +00:00
parent 5f17afc295
commit c7b2a1b5eb
5 changed files with 30 additions and 1 deletions

View file

@ -23,7 +23,7 @@ install:
$(INSTALL) quotes.lua $(STEADPATH)/quotes.lua
$(INSTALL) timer.lua $(STEADPATH)/timer.lua
$(INSTALL) kbd.lua $(STEADPATH)/kbd.lua
$(INSTALL) hotkeys.lua $(STEADPATH)/hotkeys.lua
uninstall:
$(RM) $(STEADPATH)/stead.lua

View file

@ -20,4 +20,5 @@ install:
copy dash.lua ..\bin\stead
copy timer.lua ..\bin\stead
copy kbd.lua ..\bin\stead
copy hotkeys.lua ..\bin\stead

View file

@ -90,6 +90,9 @@ go = function (self, where, back)
elseif here().__visited == nil then
ref(to).__visited = 1
end
if isDialog(ref(to)) then
dialog_rescan(ref(to))
end
end
PLAYER_MOVED = true
if need_scene then -- or isForcedsc(ref(where)) then -- i'am not sure...

18
stead/hotkeys.lua Normal file
View file

@ -0,0 +1,18 @@
require 'kbd'
stead.module_init(function()
hook_keys('1','2','3','4','5','6','7','8','9','0');
end)
game.kbd = stead.hook(game.kbd, function(f, s, down, key, ...)
if down and key >= '0' and key <= '9' then
if isDialog(here()) then
local p = seen(key);
if p then
return call(p, 'act');
end
end
return
end
return f(s, down, key, unpack(arg));
end)

View file

@ -21,6 +21,13 @@ input.key = stead.hook(input.key, function(f, s, down, key, ...)
return f(s, down, key, unpack(arg))
end)
function hook_keys(...)
local i
for i = 1, stead.table.maxn(arg) do
stead.table.insert(input.key_hooks, tostring(arg[i]));
end
end
stead.module_init(function()
input.key_hooks = {}
end)