ibm-dev-incubator / demoparser

Apache License 2.0
34 stars 10 forks source link

trigger callback at each tick #4

Closed adrz closed 5 years ago

adrz commented 5 years ago

Hi,

I was wondering if it would be possible to have a callback at each tick. I try the following snippet:

from demoparser.demofile import DemoFile
def tickend():
    print(d.current_tick)

path_file = 'astralis-vs-mibr-m3-inferno.dem'
with open(path_file, 'rb') as f:
    data = f.read()
d.add_callback('tick_end', tickend)
d.parse()

and of course i got the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: tickend() takes 0 positional arguments but 1 was given
Exception ignored in: 'demoparser.demofile.DemoFile.emit'
TypeError: tickend() takes 0 positional arguments but 1 was given
---------------------------------------------------------------------------

Cheers,

kpei commented 5 years ago
def tickend(current_tick):
    print(current_tick)
adrz commented 5 years ago
def tickend(current_tick):
    print(current_tick)

Perfect, thank you!