1
0
mirror of https://github.com/20kdc/OC-KittenOS.git synced 2024-09-28 06:31:07 +10:00
OC-KittenOS/apps/keycodes.lua
gamemanj 2ae3f9a93a Initial commit
Currently eeprog pirate-speak language is unsupported, but... oh well.
2016-10-23 13:27:16 +01:00

30 lines
579 B
Lua

local math, table = A.request("math", "table")
local app = {}
local strs = {"", "Shift-C to quit."}
local keys = {}
local function rebuildKeys()
local keylist = {}
for k, v in pairs(keys) do
if v then
table.insert(keylist, k)
end
end
table.sort(keylist)
strs[1] = ""
for _, v in ipairs(keylist) do
strs[1] = strs[1] .. v .. " "
end
end
app.key = function(ka, kc, down)
if ka == ("C"):byte() and down then
A.die()
return false
end
keys[kc] = down
rebuildKeys()
return true
end
app.get_ch = function (x, y)
return (strs[y]):sub(x, x)
end
return app, 20, 2