You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.3 KiB
Lua
60 lines
1.3 KiB
Lua
local tempTable = {}
|
|
function tempTable.unit(...)
|
|
local args = { ... }
|
|
local string = args[1]
|
|
assert(string, "No args to unit!")
|
|
for i=2, #args do
|
|
--print(type(string) .. "with" .. type(args[i]))
|
|
string = string .. string.char(31) .. args[i]
|
|
end
|
|
return string
|
|
end
|
|
|
|
|
|
function tempTable.resolve(record)
|
|
local tTable = {}
|
|
for entry in record:gmatch("[^\31]+") do
|
|
table.insert(tTable, entry)
|
|
end
|
|
return tTable
|
|
end
|
|
|
|
function tempTable.clean(record)
|
|
assert(type(record) == "string")
|
|
return record:gsub("\31", "")
|
|
end
|
|
|
|
|
|
function tempTable.pprint(record)
|
|
local cleaned, _ = record:gsub("\31","|")
|
|
return cleaned
|
|
end
|
|
|
|
|
|
function tempTable.nextIntRecord(record)
|
|
local nextR = tempTable.clean(record:match("^.-\31"))
|
|
record = record:gsub("^.-\31","")
|
|
return tonumber(nextR), record
|
|
end
|
|
|
|
|
|
function tempTable.nextStringRecord(record)
|
|
local nextR = tempTable.clean(record:match("^.-\31"))
|
|
record = record:gsub("^.-\31","")
|
|
return nextR, record
|
|
end
|
|
|
|
|
|
function tempTable.getIntRecords(number, record)
|
|
local tTable = {}
|
|
local nextR
|
|
for i = 1, number -1 do
|
|
nextR, record = tempTable.nextIntRecord(record)
|
|
table.insert(tTable, nextR)
|
|
end
|
|
local last = tempTable.clean(record:gsub("^.-\31",""))
|
|
table.insert(tTable, tonumber(last))
|
|
return unpack(tTable)
|
|
end
|
|
return tempTable
|