rework key input handling, add more script events for UI and implement console history

This commit is contained in:
Eduardo Bart
2011-08-28 18:32:24 -03:00
parent 7242dfc9ee
commit 8aadea2a96
12 changed files with 494 additions and 314 deletions

View File

@@ -0,0 +1,14 @@
function string:split(sep)
local t = { }
local function helper(word)
table.insert(t, word)
return ""
end
if not self:gsub("%w+", helper):find("%S") then
return t
end
end
function string:starts(start)
return self:sub(1, #start) == start
end

View File

@@ -0,0 +1,34 @@
function table.dump(t, depth)
if not depth then depth = 0 end
for k,v in pairs(t) do
str = string.rep(' ', depth * 2) .. k .. ': '
if type(v) ~= "table" then
print(str .. v)
else
print(str)
table.dump(v, depth+1)
end
end
end
function table.copy(t)
local res = {}
for k,v in pairs(t) do
res[k] = v
end
return res
end
function table.selective_copy(t, keys)
local res = { }
for i,v in ipairs(keys) do
res[v] = t[v]
end
return res
end
function table.merge(t, src)
for k,v in pairs(src) do
t[k] = v
end
end