aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/lua/count_effects.lua
blob: f4469abbb90a0fb72a554ea463bda6b7f985ade3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function tostr(t)
    local str = ""
    for k, v in next, t do
        if #str > 0 then
            str = str .. ", "
        end
        if type(k) == "number" then
            str = str .. "[" .. k .. "] = "
        else
            str = str .. tostring(k) .. " = "
        end
        if type(v) == "table" then
            str = str .. "{ " .. tostr(v) .. " }"
        else
            str = str .. tostring(v)
        end
    end
    return str
end

function sk_scrape_startcanvas(c, fileName) end

function sk_scrape_endcanvas(c, fileName) end

local effects = {}

function count_fields(t)
    for k, v in next, t do
        effects[k] = (effects[k] or 0) + 1
    end
end

local total_paints = 0;

function sk_scrape_accumulate(t)
    if (t.paint) then
        total_paints = total_paints + 1
        count_fields(t.paint:getEffects())
    end
end

function sk_scrape_summarize()
    io.write("total paints ", total_paints, " ", tostr(effects), "\n");
end