count_effects.lua 965 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. function tostr(t)
  2. local str = ""
  3. for k, v in next, t do
  4. if #str > 0 then
  5. str = str .. ", "
  6. end
  7. if type(k) == "number" then
  8. str = str .. "[" .. k .. "] = "
  9. else
  10. str = str .. tostring(k) .. " = "
  11. end
  12. if type(v) == "table" then
  13. str = str .. "{ " .. tostr(v) .. " }"
  14. else
  15. str = str .. tostring(v)
  16. end
  17. end
  18. return str
  19. end
  20. function sk_scrape_startcanvas(c, fileName) end
  21. function sk_scrape_endcanvas(c, fileName) end
  22. local effects = {}
  23. function count_fields(t)
  24. for k, v in next, t do
  25. effects[k] = (effects[k] or 0) + 1
  26. end
  27. end
  28. local total_paints = 0;
  29. function sk_scrape_accumulate(t)
  30. if (t.paint) then
  31. total_paints = total_paints + 1
  32. count_fields(t.paint:getEffects())
  33. end
  34. end
  35. function sk_scrape_summarize()
  36. io.write("total paints ", total_paints, " ", tostr(effects), "\n");
  37. end