Mercurial > wow > breuesk
comparison Lists.lua @ 44:8913e7d79cad
Refactoring some very simple items to a Utility file
author | John@Yosemite-PC |
---|---|
date | Thu, 15 Mar 2012 22:58:54 -0400 |
parents | 4109683c3172 |
children | 8d3187b12443 |
comparison
equal
deleted
inserted
replaced
43:4109683c3172 | 44:8913e7d79cad |
---|---|
103 raidNameP = {} | 103 raidNameP = {} |
104 raidIdP = {} | 104 raidIdP = {} |
105 reserveIdP = {} | 105 reserveIdP = {} |
106 personName2id = {} | 106 personName2id = {} |
107 end | 107 end |
108 function tcopy(to, from) | |
109 for k,v in pairs(from) do | |
110 if(type(v)=="table") then | |
111 to[k] = {} | |
112 tcopy(to[k], v); | |
113 else | |
114 to[k] = v; | |
115 end | |
116 end | |
117 end | |
118 local shallowCopy = function(t) | |
119 local u = { } | |
120 for k, v in pairs(t) do u[k] = v end | |
121 return setmetatable(u, getmetatable(t)) | |
122 end | |
123 | 108 |
124 -- Debugging {{{ | 109 -- Debugging {{{ |
125 function PrettyPrintList(listIndex) | 110 function PrettyPrintList(listIndex) |
126 local list = lists[listIndex] | 111 local list = lists[listIndex] |
127 print("List: " .. list.name .. " (" .. listIndex .. ") - last modified " .. date("%m/%d/%y %H:%M:%S", list.time) .. " (",list.time,")" ) | 112 print("List: " .. list.name .. " (" .. listIndex .. ") - last modified " .. date("%m/%d/%y %H:%M:%S", list.time) .. " (",list.time,")" ) |
148 if type(v) == "function" then | 133 if type(v) == "function" then |
149 print("function "..i.."()") | 134 print("function "..i.."()") |
150 end | 135 end |
151 end | 136 end |
152 end | 137 end |
153 function PrintTable(table, depth) | |
154 depth = depth or "" | |
155 if not table then return end | |
156 if #depth > 3*5 then print(depth.."Recursion too deep - stopping"); return end | |
157 for i,v in pairs(table) do | |
158 if( type(v) == "string" ) then | |
159 print(depth .. i .. " - " .. v) | |
160 elseif( type(v) == "number" ) then | |
161 print(depth .. i .. " - " .. tostring(v)) | |
162 elseif( type(v) == "table" ) then | |
163 print(depth .. i .." - ") | |
164 PrintTable(v,depth.." ") | |
165 elseif( type(v) == "boolean" ) then | |
166 print(depth .. i .. " - " .. tostring(v)) | |
167 elseif( type(v) == "function" ) then | |
168 print(depth .. "function " .. i .. "()") | |
169 else | |
170 print(depth .. i .. " - not sure how to print type: " .. type(v) ) | |
171 end | |
172 end | |
173 end | |
174 | |
175 function PrintRaidAndReserve() | 138 function PrintRaidAndReserve() |
176 print("RaidNameP") | 139 print("RaidNameP") |
177 PrintTable(raidNameP) | 140 PrintTable(raidNameP) |
178 print("RaidIdP") | 141 print("RaidIdP") |
179 PrintTable(raidIdP) | 142 PrintTable(raidIdP) |