36 lines
760 B
Lua
36 lines
760 B
Lua
return function(argv, con)
|
|
-- /Ckeys /S text
|
|
local ch = {'Y', 'N'}
|
|
local cs = false
|
|
local i = 2
|
|
while argv[i] do
|
|
local v = argv[i]:upper()
|
|
if v:sub(1,1) == '/'
|
|
then table.remove(argv, i)
|
|
else i = i + 1
|
|
end
|
|
if v:sub(1, 2) == '/C'
|
|
and #v > 2 then
|
|
ch = {}
|
|
for l in v:sub(3):gmatch '.' do table.insert(ch, l) end
|
|
elseif v == '/S' then cs = true
|
|
end
|
|
end
|
|
con.print(table.concat(argv, ' ', 2))
|
|
con.print(' ['.. table.concat(ch, ',') ..'] ')
|
|
con.print('('.. ch[1] ..') ')
|
|
local chr = con.getch(10)
|
|
if not chr then chr = ch[1] end
|
|
|
|
local ret = 0
|
|
for k, v in pairs(ch) do
|
|
if v == chr
|
|
or (not cs and v:upper() == chr:upper())
|
|
then ret = k end
|
|
end
|
|
|
|
con.print '\n'
|
|
|
|
return ret
|
|
end
|