Differences From Artifact [99c5f4dbba]:
- File lib/tbl.lua — part of check-in [956134c50b] at 2020-08-11 21:39:39 on branch trunk — initial commit (user: lexi, size: 815) [annotate] [blame] [check-ins using]
To Artifact [5997708826]:
- File lib/tbl.lua — part of check-in [9ef6cbcf31] at 2020-08-28 14:08:57 on branch trunk — add recipes, cookbooks, disassembly (to create recipes from items), attunement, farcasters, and portals; various edits for bug fixes and improvements (user: lexi, size: 1036) [annotate] [blame] [check-ins using]
1 2 3 4 5 6 7 8 |
local fn = {}
fn.copy = function(t)
local new = {}
for i,v in pairs(t) do new[i] = v end
setmetatable(new,getmetatable(t))
return new
end
|
> > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
local fn = {}
fn.shuffle = function(list)
for i = #list, 2, -1 do
local j = math.random(i)
list[i], list[j] = list[j], list[i]
end
end
fn.scramble = function(list)
local new = table.copy(list)
fn.shuffle(new)
return new
end
fn.copy = function(t)
local new = {}
for i,v in pairs(t) do new[i] = v end
setmetatable(new,getmetatable(t))
return new
end
|