Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,15 +522,16 @@
- `start` starts the previously set timer, so `/timer 0 start`.
- `pause` OR `stop` pauses the timer that's currently running, so `/timer 0 pause`.
- `unset` OR `hide` hides the timer for it to no longer show up, so `/timer 0 hide`.
* **format_timer** `<id> <format>`
* **timer\_format** `<id> <format>`
- Format the timer in the current area or hub.
- Example of format: `Time Left: hh:mm`
- Default format: `hh:mm:ss.zzz`
- Example of format: `'Time Left:' hh:mm`, where 'Time Left:' is surrounded by single quotes so it's not affected by the formatting, hh stands for hours and mm stands for minutes.
- Default format: `hh:mm:ss.zzz` where hh stands for hours, mm stands for minutes, ss stands for seconds, and zzz stands for milliseconds.
- For more information on how to implement your format, [go here!](https://doc.qt.io/qt-6/qtime.html#toString)
* **timer_interval** `<id> <interval>`
- Set timer interval in the current area or hub.
- Example: `/timer_interval 1 15m`
- Default interval: `/timer_interval 1 16ms`
* **timer\_interval** `<id> <interval>`
- Set the timer's interval, which is how often it fires in milliseconds.
- If timer interval is not written, it will reset the interval to the default value, which is 16.
- Example: `/timer_interval 1 16`
- Default interval: `/timer_interval 1 16`
## Musiclists
* **musiclist\_add** `<local/area/hub>` `<Category>` `<MusicName>` `[Length]` `[Path]`
- Allow you to add a song in a loaded musiclist!
Expand Down
8 changes: 4 additions & 4 deletions server/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ def update_timers(self, client, running_only=False):
if timer.started:
current_time = timer.target - arrow.get()
int_time = int(current_time.total_seconds()) * 1000
client.send_timer_set_time(0, int_time, timer.started)
client.send_timer_set_time(0, int_time, timer.started, timer.format, timer.interval)
elif not running_only:
client.send_timer_set_time(0, None, False)

Expand All @@ -754,7 +754,7 @@ def update_timers(self, client, running_only=False):
if timer.started:
current_time = timer.target - arrow.get()
int_time = int(current_time.total_seconds()) * 1000
client.send_timer_set_time(timer_id + 1, int_time, timer.started)
client.send_timer_set_time(timer_id + 1, int_time, timer.started, timer.format, timer.interval)
elif not running_only:
client.send_timer_set_time(timer_id + 1, None, False)

Expand Down Expand Up @@ -927,10 +927,10 @@ def send_owner_ic(self, bg, cmd, *args):
if c.area.background != bg:
c.send_command("BN", c.area.background)

def send_timer_set_time(self, timer_id=None, new_time=None, start=False):
def send_timer_set_time(self, timer_id=None, new_time=None, start=False, format=None, interval=None):
"""Broadcast a timer to all clients in this area."""
for c in self.clients:
c.send_timer_set_time(timer_id, new_time, start)
c.send_timer_set_time(timer_id, new_time, start, format, interval)

def broadcast_ooc(self, msg):
"""
Expand Down
4 changes: 2 additions & 2 deletions server/area_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,10 @@ def send_remote_command(self, area_list, cmd, *args):
a.send_command(cmd, *args)
a.send_owner_command(cmd, *args)

def send_timer_set_time(self, timer_id=None, new_time=None, start=False):
def send_timer_set_time(self, timer_id=None, new_time=None, start=False, format=None, interval=None):
"""Broadcast a timer to all areas in this hub."""
for area in self.areas:
area.send_timer_set_time(timer_id, new_time, start)
area.send_timer_set_time(timer_id, new_time, start, format, interval)

def broadcast_area_list(self, refresh=False):
"""Global update of all areas for the client music lists in the hub."""
Expand Down
25 changes: 8 additions & 17 deletions server/client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,11 @@ def send_player_count(self):
limit = self.server.config["playerlimit"]
self.send_ooc(f"👥{players}/{limit} players online.")

def send_timer_set_time(self, timer_id=None, new_time=None, start=False):
def send_timer_set_time(self, timer_id=None, new_time=None, start=False, format=None, interval=None):
if self.software == "DRO":
# configuration. There's no situation where these values are different on KFO-Server
self.send_timer_set_step_length(timer_id, -16) # 16 milliseconds, matches AO
self.send_timer_set_firing_interval(timer_id, 16) # 16 milliseconds, matches AO
self.send_timer_set_step_length(timer_id, -timer.interval) # 16 milliseconds, matches AO
self.send_timer_set_firing_interval(timer_id, timer.interval) # 16 milliseconds, matches AO

self.send_command("TST", timer_id, new_time) # set time
if start:
Expand All @@ -366,19 +366,10 @@ def send_timer_set_time(self, timer_id=None, new_time=None, start=False):
timer = self.area.area_manager.timer
else:
timer = self.area.timers[timer_id-1]
self.send_command("TF", timer_id, timer.format, new_time)
self.send_command("TIN", timer_id, timer.interval)

def send_timer_set_interval(self, timer_id, timer):
if timer.started:
current_time = timer.target - arrow.get()
current_time = int(current_time.total_seconds()) * 1000
else:
current_time = int(timer.static.total_seconds()) * 1000
if timer_id == 0:
self.area.area_manager.send_timer_set_time(timer_id, current_time, timer.started)
else:
self.area.send_timer_set_time(timer_id, current_time, timer.started)
if format:
self.send_command("TF", timer_id, format, new_time)
if interval:
self.send_command("TIN", timer_id, interval)

def send_timer_set_step_length(self, timer_id=None, new_step_length=None):
if self.software == "DRO":
Expand All @@ -390,7 +381,7 @@ def send_timer_set_firing_interval(self, timer_id=None, new_firing_interval=None
if self.software == "DRO":
self.send_command("TSF", timer_id, new_firing_interval) #set firing
else:
pass # no ao equivalent
self.send_command("TIN", timer_id, new_firing_interval)

def is_valid_name(self, name):
"""
Expand Down
41 changes: 18 additions & 23 deletions server/commands/roleplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"ooc_cmd_timer",
"ooc_cmd_demo",
"ooc_cmd_trigger",
"ooc_cmd_format_timer",
"ooc_cmd_timer_format",
"ooc_cmd_timer_interval",
]

Expand Down Expand Up @@ -825,9 +825,9 @@ def ooc_cmd_timer(client, arg):
s = int(not timer.started)
static_time = int(timer.static.total_seconds()) * 1000
if timer_id == 0:
client.area.area_manager.send_timer_set_time(timer_id, static_time, timer.started)
client.area.area_manager.send_timer_set_time(timer_id, static_time, timer.started, timer.format, timer.interval)
else:
client.area.send_timer_set_time(timer_id, static_time, timer.started)
client.area.send_timer_set_time(timer_id, static_time, timer.started, timer.format, timer.interval)
client.send_ooc(f"Timer {timer_id} is at {timer.static}")

if timer_id == 0:
Expand Down Expand Up @@ -954,12 +954,12 @@ def ooc_cmd_trigger(client, arg):
client.send_ooc(f'Changed to Call "{val}" on trigger "{trig}"')


def ooc_cmd_format_timer(client, arg):
def ooc_cmd_timer_format(client, arg):
"""
Format the timer
Usage: /format_timer <Timer_iD> <Format>
Usage: /timer_format <Timer_iD> <Format>
"""
args = shlex.split(arg)
args = arg.split()
try:
args[0] = int(args[0])
except:
Expand All @@ -980,25 +980,20 @@ def ooc_cmd_format_timer(client, arg):
else:
client.send_ooc("You cannot change timer format if you are at least CM")
return
timer.format = args[1:]
if timer.set:
if timer.started:
current_time = timer.target - arrow.get()
current_time = int(current_time.total_seconds()) * 1000
else:
current_time = int(timer.static.total_seconds()) * 1000
if args[0] == 0:
client.area.area_manager.send_timer_set_time(args[0], current_time, timer.started)
else:
client.area.send_timer_set_time(args[0], current_time, timer.started)
if len(args) <= 1:
args.append("hh:mm:ss.zzz")
timer.format = ' '.join(args[1:])
area = client.area
for c in area.clients:
area.update_timers(c)
client.send_ooc(f"Timer {args[0]} format: '{args[1]}'")


def ooc_cmd_timer_interval(client, arg):
"""
Set timer interval
If timer interval is not written than will show default timer interval (16ms)
Example: /timer_interval 1 15m
Set the timer's interval, which is how often it fires in milliseconds.
If timer interval is not written, it will reset the interval to the default value, which is 16 .
Example: /timer_interval 1 16
Usage: /timer_interval <Timer_ID> <Interval>
"""
args = shlex.split(arg)
Expand Down Expand Up @@ -1026,9 +1021,9 @@ def ooc_cmd_timer_interval(client, arg):
if len(args) == 1:
timer.interval = 16
else:
timer.interval = pytimeparse.parse(args[1]) * 1000
timer.interval = int(args[1])
except:
raise ArgumentError("Interval value not valid!")
if timer.set:
client.send_timer_set_interval(args[0], timer)
client.send_ooc(f"Timer {args[0]} interval is set to '{args[1]}'")
client.send_timer_set_firing_interval(args[0], timer)
client.send_ooc(f"Timer {args[0]} interval is set to '{timer.interval}'")