forked from MakeSureDudeDies/Lua-Table-Reconstructor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tablegen.lua
33 lines (28 loc) · 774 Bytes
/
tablegen.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--[[
LuaTableReconstructor - Made by Dottik
Generate random tables which nest tables, numbers and strings, with indexes that are numbers and strings.
]]
local tNesting = 0
local function genTable(base, maxNesting, depth)
if i > 50 then
table.insert(base, "END")
return base
end
local r = math.random(50, 200)
for _ = 0, r do
local num = math.random(0, 2)
if num == 1 then
table.insert(base, tostring(depth))
elseif num == 2 then
table.insert(base, tonumber(depth))
else
if tNesting < maxNesting then
tNesting = tNesting + 1
table.insert(base, genTable({}, maxNesting, depth + 5))
end
end
end
return genTable(base, maxNesting, depth + 1)
end
-- Generates tables, used for testing LuaTableReconstructor.lua
return genTable