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