Below is the adapted code:
Code: Select all
default pauseddict = {}
init python:
def _insert(name, time):
store.pauseddict[name] = time
def fading_pause(channel="music", pause="toggle", fade=None, filename=None):
if fade is None:
fade = 0
if pause == "toggle":
pause = renpy.music.get_playing(channel)
if pause:
current_track = renpy.music.get_playing(channel)
if current_track:
current_pos = renpy.music.get_pos(channel)
# Save the current track information
_insert(current_track, current_pos)
renpy.music.stop(channel, fade)
else:
if filename is None:
name, time = store.pauseddict.popitem()
else:
name, time = store.pauseddict.pop(filename, (None, None))
if name and time is not None:
# Check if the <from x> tag already exists to avoid duplication
if "<from" not in name:
fn = "<from {}>".format(time) + name
else:
fn = name
renpy.music.play(fn, channel=channel, fadein=fade)
I'm reaching out to see if anyone can help identify any potential issues with this code or suggest improvements to make it work more effectively. I appreciate any insights or advice you can offer.