pdinklag / MinecraftStats

A Minecraft player statistics browser for the web - supports 1.13 and later!
https://discord.gg/brH5PGG8By
Other
227 stars 53 forks source link

Cant make glass broken #55

Closed lukeeexd closed 5 years ago

lukeeexd commented 5 years ago

Trying to track all glass blocks and glass panes broken. Trying to use other stats as templates but just cant get it to work. Could you help?

from mcstats import mcstats
mcstats.registry.append(
    mcstats.MinecraftStat(
        'break_glass',
        {
            'title': 'Glassbreaker',
            'desc': 'Glass broken',
            'unit': 'int',
        },
        mcstats.StatSumMatchReader(
            ['minecraft:mined'],
            ['minecraft:glass','minecraft:.*stained_glass']),
            ['minecraft:glass','minecraft:.*glass_pane']),
    ])
))
pdinklag commented 5 years ago

Well, your syntax is broken and I believe you're using StatSumMatchReader wrong. First is a path (which is minecraft:mined), second is one array of patterns to match.

Try it like this:

from mcstats import mcstats
mcstats.registry.append(
    mcstats.MinecraftStat(
        'break_glass',
        {
            'title': 'Glassbreaker',
            'desc': 'Glass broken',
            'unit': 'int',
        },
        mcstats.StatSumMatchReader(
            ['minecraft:mined'],
            ['minecraft:glass','minecraft:.*glass_pane','minecraft:.*stained_glass']),
    ))

It also appears that stained glass is missing from my "place glass" stat, eh?

lukeeexd commented 5 years ago
from mcstats import mcstats
mcstats.registry.append(
    mcstats.MinecraftStat(
        'break_glass',
        {
            'title': 'Glassbreaker',
            'desc': 'Glass broken',
            'unit': 'int',
        },
        mcstats.StatSumMatchReader(
            ['minecraft:mined'],
            ['minecraft:glass','minecraft:.*glass_pane','minecraft:.*stained_glass']),
    ])
))

Using that gives. And yes it is missing from place glass :P

  File "update.py", line 17, in <module>
    from mcstats.stats import *
  File "/home/www/html/stats/mcstats/stats/break_glass.py", line 13
    ])
    ^
SyntaxError: invalid syntax
minecraft@TWS:~/scripts$

And sublime has these red https://i.imgur.com/sscXECM.png

pdinklag commented 5 years ago

Yeah that whole line needs to be gone. Updated my previous reply.

lukeeexd commented 5 years ago

Yeah that whole line needs to be gone. Updated my previous reply.

Yeah that worked. How would I add stained glass to the place_glass stat?

pdinklag commented 5 years ago

Same way, add 'minecraft:.*stained_glass' to the stat reader's second array. Will open an issue and fix it soon.

lukeeexd commented 5 years ago

Same way, add 'minecraft:.*stained_glass' to the stat reader's second array. Will open an issue and fix it soon.

tyty