Mercurial > wow > ouroloot
comparison LibFarmbuyer.lua @ 45:1001dd95dbeb
If tekDebug is found, feed debugging messages there instead of print(); 'alsolog' functionality unchanged.
| author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
|---|---|
| date | Fri, 20 Jan 2012 11:48:38 +0000 |
| parents | 8f7ec6ccf5e3 |
| children | 7af58a7dce7d |
comparison
equal
deleted
inserted
replaced
| 44:a561a967b5e6 | 45:1001dd95dbeb |
|---|---|
| 8 Evaluates to true if I'm hacking on something. | 8 Evaluates to true if I'm hacking on something. |
| 9 | 9 |
| 10 - tableprint(t[,f]) | 10 - tableprint(t[,f]) |
| 11 A single print() call to the contents of T, including nils; strings are | 11 A single print() call to the contents of T, including nils; strings are |
| 12 cleaned up with respect to embedded '|'/control chars. If a function F is | 12 cleaned up with respect to embedded '|'/control chars. If a function F is |
| 13 passed, calls that instead of print(). Returns the results of F, or the | 13 passed, calls that instead of print(). Returns the accumulated string and |
| 14 text string passed to print(), depending on which was used. | 14 either T or the returned values of F, depending on which was used. |
| 15 | 15 |
| 16 - safeprint(...) | 16 - safeprint(...) |
| 17 Same as tableprint() on the argument list. Returns the results of tableprint. | 17 Same as tableprint() on the argument list. Returns the results of tableprint. |
| 18 Generates some garbage. | |
| 18 | 19 |
| 19 - safeiprint(...) | 20 - safeiprint(...) |
| 20 Same as safeprint() but with <index> numbers inserted. Returns the results | 21 Same as safeprint() but with <index> numbers inserted. Returns the results |
| 21 of tableprint. | 22 of tableprint. Generates some garbage. |
| 22 Ex: safeiprint(a,b,c) --> <1>,a,<2>,b,<3>,c | 23 Ex: safeiprint(a,b,c) --> <1>,a,<2>,b,<3>,c |
| 24 | |
| 25 - safefprint/safefiprint(f,...) | |
| 26 Takes a function F as first parameter, for passing to tableprint(). | |
| 23 | 27 |
| 24 - t = StaticPopup(t) | 28 - t = StaticPopup(t) |
| 25 Fills out "typical" settings inside T, especially if T contains any kind | 29 Fills out "typical" settings inside T, especially if T contains any kind |
| 26 of editbox: | 30 of editbox: |
| 27 + cannot accept an empty editbox | 31 + cannot accept an empty editbox |
| 48 | 52 |
| 49 - new(...), del(t), copy(t), clear() | 53 - new(...), del(t), copy(t), clear() |
| 50 Ditto for table recycling. | 54 Ditto for table recycling. |
| 51 ]] | 55 ]] |
| 52 | 56 |
| 53 local MAJOR, MINOR = "LibFarmbuyer", 13 | 57 local MAJOR, MINOR = "LibFarmbuyer", 14 |
| 54 assert(LibStub,MAJOR.." requires LibStub") | 58 assert(LibStub,MAJOR.." requires LibStub") |
| 55 local lib = LibStub:NewLibrary(MAJOR, MINOR) | 59 local lib = LibStub:NewLibrary(MAJOR, MINOR) |
| 56 if not lib then return end | 60 if not lib then return end |
| 57 | 61 |
| 58 _G[MAJOR] = lib | 62 _G[MAJOR] = lib |
| 104 end | 108 end |
| 105 function lib.safeprint(...) | 109 function lib.safeprint(...) |
| 106 local args = { n=select('#',...), ... } | 110 local args = { n=select('#',...), ... } |
| 107 return lib.tableprint(args) | 111 return lib.tableprint(args) |
| 108 end | 112 end |
| 113 function lib.safefprint(f,...) | |
| 114 local args = { n=select('#',...), ... } | |
| 115 return lib.tableprint(args,f) | |
| 116 end | |
| 109 function lib.safeiprint(...) | 117 function lib.safeiprint(...) |
| 110 local args = { n=select('#',...), ... } | 118 local args = { n=select('#',...), ... } |
| 111 local last = args.n | 119 local last = args.n |
| 112 while last > 0 do | 120 while last > 0 do |
| 113 table.insert (args, last, "<"..last..">") | 121 table.insert (args, last, "<"..last..">") |
| 114 last = last - 1 | 122 last = last - 1 |
| 115 end | 123 end |
| 116 args.n = 2 * args.n | 124 args.n = 2 * args.n |
| 117 return lib.tableprint(args) | 125 return lib.tableprint(args) |
| 118 end | 126 end |
| 127 function lib.safefiprint(f,...) | |
| 128 local args = { n=select('#',...), ... } | |
| 129 local last = args.n | |
| 130 while last > 0 do | |
| 131 table.insert (args, last, "<"..last..">") | |
| 132 last = last - 1 | |
| 133 end | |
| 134 args.n = 2 * args.n | |
| 135 return lib.tableprint(args,f) | |
| 136 end | |
| 119 function lib.tableprint(t,f) | 137 function lib.tableprint(t,f) |
| 120 for i = 1, (tonumber(t.n) or #t) do | 138 for i = 1, (tonumber(t.n) or #t) do |
| 121 t[i] = tostring(t[i]):gsub('\124','\124\124') | 139 t[i] = tostring(t[i]):gsub('\124','\124\124') |
| 122 :gsub('(%c)', undocontrol) | 140 :gsub('(%c)', undocontrol) |
| 123 end | 141 end |
| 124 local msg = tconcat(t,' ', i, tonumber(t.n) or #t) | 142 local msg = tconcat(t,' ', i, tonumber(t.n) or #t) |
| 125 if f then | 143 if type(f) == 'function' then |
| 126 return f(msg) | 144 return msg,f(msg) |
| 127 else | 145 else |
| 128 print(msg) | 146 print(msg) |
| 129 return msg,t | 147 return msg,t |
| 130 end | 148 end |
| 131 end | 149 end |
