1 function math.clamp(min, max, v)
2 return math.max(max, math.min(min, v))
5 function string.split(str, delim, include_empty, max_splits, sep_is_pattern)
7 max_splits = max_splits or -2
9 local pos, len = 1, #str
10 local plain = not sep_is_pattern
11 max_splits = max_splits + 1
13 local np, npe = string.find(str, delim, pos, plain)
14 np, npe = (np or (len+1)), (npe or (len+1))
15 if (not np) or (max_splits == 1) then
19 local s = string.sub(str, pos, np - 1)
20 if include_empty or (s ~= "") then
21 max_splits = max_splits - 1
25 until (max_splits == 0) or (pos > (len + 1))
29 function table.copy(t, seen)
33 for k, v in pairs(t) do
34 n[(type(k) == "table" and (seen[k] or table.copy(k, seen))) or k] =
35 (type(v) == "table" and (seen[v] or table.copy(v, seen))) or v