1 --------------------------------------------------------------------------------
2 function dump(o, dumped)
4 if type(o) == "number" then
6 elseif type(o) == "string" then
7 return string.format("%q", o)
8 elseif type(o) == "table" then
10 return "<circular reference>"
14 for k,v in pairs(o) do
15 t[#t+1] = "" .. k .. " = " .. dump(v, dumped)
17 return "{" .. table.concat(t, ", ") .. "}"
18 elseif type(o) == "boolean" then
20 elseif type(o) == "function" then
22 elseif type(o) == "userdata" then
24 elseif type(o) == "nil" then
27 error("cannot dump a " .. type(o))
32 --------------------------------------------------------------------------------
33 function string:split(sep)
34 local sep, fields = sep or ",", {}
35 local pattern = string.format("([^%s]+)", sep)
36 self:gsub(pattern, function(c) fields[#fields+1] = c end)
40 --------------------------------------------------------------------------------
41 function string:trim()
42 return (self:gsub("^%s*(.-)%s*$", "%1"))
45 --------------------------------------------------------------------------------
46 engine.get_game = function(index)
47 local games = game.get_games()
49 if index > 0 and index <= #games then
56 --------------------------------------------------------------------------------
57 function fs_escape_string(text)
59 while (text:find("\r\n") ~= nil) do
60 local newtext = text:sub(1,text:find("\r\n")-1)
61 newtext = newtext .. " " .. text:sub(text:find("\r\n")+3)
66 while (text:find("\n") ~= nil) do
67 local newtext = text:sub(1,text:find("\n")-1)
68 newtext = newtext .. " " .. text:sub(text:find("\n")+1)
73 while (text:find("\r") ~= nil) do
74 local newtext = text:sub(1,text:find("\r")-1)
75 newtext = newtext .. " " .. text:sub(text:find("\r")+1)
80 text = text:gsub("%[","%[%[")
81 text = text:gsub("]","]]")
82 text = text:gsub(";"," ")
87 --------------------------------------------------------------------------------
88 function explode_textlist_event(text)
93 local parts = text:split(":")
96 retval.typ = parts[1]:trim()
97 retval.index= tonumber(parts[2]:trim())
99 if type(retval.index) ~= "number" then