Hendrik Langer
2 years ago
3 changed files with 35 additions and 29 deletions
@ -1,6 +1,6 @@ |
|||||
[Julia] |
[Julia] |
||||
timestamp = 1680134005.6927342 |
current_tick = 630 |
||||
|
|
||||
[Hendrik] |
[Hendrik] |
||||
timestamp = 1680149214.3503995 |
current_tick = 350 |
||||
|
|
||||
|
@ -1,21 +1,23 @@ |
|||||
import time |
import time |
||||
|
|
||||
class Event: |
class Event: |
||||
def __init__(self, time_start, time_stop, chance, command): |
def __init__(self, tick_start, tick_stop, chance, repeat, command): |
||||
self.time_start = time_start |
self.tick_start = tick_start |
||||
self.time_stop = time_stop |
self.tick_stop = tick_stop |
||||
self.chance = chance |
self.chance = chance |
||||
|
self.repeat = repeat |
||||
self.command = command |
self.command = command |
||||
self.executed = 0 |
self.executed = 0 |
||||
def __str__(self): |
def __str__(self): |
||||
return str("Event starting at timestamp {}".format(self.time_start)) |
return str("Event starting at time {}".format(self.tick_start)) |
||||
def loop(self, bot): |
def loop(self, bot, tick): |
||||
if time.time() - bot.timestamp >= self.time_start: |
if tick >= self.tick_start: |
||||
if time.time() - bot.timestamp < self.time_stop: |
if tick < self.tick_stop: |
||||
self.execute() |
self.execute(bot, tick) |
||||
elif (self.time_stop == 0 or self.time_stop == self.time_start) and self.executed == 0: |
elif (self.tick_stop == 0 or self.tick_stop == self.tick_start) and self.executed == 0: |
||||
self.execute() |
self.execute(bot, tick) |
||||
def execute(self, bot): |
def execute(self, bot, tick): |
||||
|
print("event executed for " + bot.name + ". current tick: " + str(tick) + " event: " + str(self.command)) |
||||
if self.command.startswith('printtime'): |
if self.command.startswith('printtime'): |
||||
print(time.time()) |
print(time.time()//1000) |
||||
self.executed += 1 |
self.executed += 1 |
||||
|
Loading…
Reference in new issue