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 1 local fn = {} 2 + 3 +fn.shuffle = function(list) 4 + for i = #list, 2, -1 do 5 + local j = math.random(i) 6 + list[i], list[j] = list[j], list[i] 7 + end 8 +end 9 + 10 +fn.scramble = function(list) 11 + local new = table.copy(list) 12 + fn.shuffle(new) 13 + return new 14 +end 2 15 3 16 fn.copy = function(t) 4 17 local new = {} 5 18 for i,v in pairs(t) do new[i] = v end 6 19 setmetatable(new,getmetatable(t)) 7 20 return new 8 21 end