add shop count to report
[smartshop.git] / init.lua
index 8c172ca..c1b79ef 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -515,6 +515,17 @@ smartshop.get_item_count = function(name)
    return sum\r
 end\r
 \r
+smartshop.get_shop_count = function(name)\r
+   sum = 0\r
+   if smartshop.itemstats[name] == nil then\r
+      return 0\r
+   end\r
+   for i, k in pairs(smartshop.itemstats[name]) do\r
+      sum = sum + 1\r
+   end\r
+   return sum\r
+end\r
+\r
 smartshop.get_item_price = function(name)\r
    sum = smartshop.get_item_count(name)\r
    if smartshop.itemprices[name] == nil then\r
@@ -544,6 +555,7 @@ minetest.register_chatcommand("smstats", {
                end\r
                sum = smartshop.get_item_count(name)\r
                minetest.chat_send_player(plname, "Number of items: "..sum)\r
+               minetest.chat_send_player(plname, "Number of shops offering item: "..smartshop.get_shop_count(name))\r
                if sum == 0 then\r
                   return\r
                end\r
@@ -565,7 +577,7 @@ minetest.register_chatcommand("smreport", {
           for i,k in pairs(smartshop.itemstats) do\r
              local count = smartshop.get_item_count(i)\r
              local price = smartshop.get_item_price(i)\r
-             file:write(i.." "..count.." "..string.format("%.3f", price).."\n")\r
+             file:write(i.." "..count.." "..string.format("%.3f", price).." "..smartshop.get_shop_count(i).."\n")\r
           end\r
           file:close()\r
        end,\r