Bug with on-screen music title

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
clannadman

Bug with on-screen music title

#1 Post by clannadman » Tue Jun 04, 2013 3:13 pm

A while back, I started a game and put it on hold. I've recently come back to it. In the game, there's an on screen 'music player', literally coding that shows the title of the track that's currently playing. I've just come back to it and boosted the resolution from 800x600 to 1280x800. Now there are issues with getting the thing to work.

Here's the coding for the music player:

screens:

Code: Select all

#On Screen Music Player
#
#This is where the on screen mp3 player thing is that shows the titles of the tracks


screen playing_music:
    $ playing = renpy.music.get_playing(6)
    if playing is not None:
        $ playing = musictitles[playing]
        text playing[0] xpos 0.1 ypos 0.1 color playing[1] size playing[2] #font playing[3]
    else:
        text "No Music Playing" xpos 0.1 ypos 0.1
script:

Code: Select all

$ musictitles = {"music/jechantes.mp3":("Je Chantes","#00FF00",20)}
    $ musictitles = {"music/fat girl.mp3":("Fat Girl","#00FF00",20)}

python:
        def ambient(songlist, interval):
            playlist = ["music/pause.wav"]
            for song in songlist:
                playlist.append(song)
                j = renpy.random.randint(2, interval)
                for i in range(0, j):
                    playlist.append("music/pause.wav")
            return renpy.music.play(playlist, channel=6)

label start:
    scene bgcar
    with fade
    
    $ ambient(("music/jechantes.mp3","music/fat girl.mp3"), 4)
    $ renpy.pause(.25)
    show screen playing_music

"I recently lost my job."
This is the traceback I get:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 77, in script
  File "game/screens.rpy", line 506, in python
KeyError: 'music/pause.wav'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\execution.py", line 288, in run
    node.execute()
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\ast.py", line 453, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\exports.py", line 757, in say
    who(what, interact=interact)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\character.py", line 795, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\character.py", line 671, in do_display
    **display_args)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\character.py", line 474, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\ui.py", line 237, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 1853, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 2092, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 252, in visit_all
    callback(self)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 2092, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\screen.py", line 166, in per_interact
    self.update()
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\screen.py", line 266, in update
    self.screen.function(**self.scope)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\screenlang.py", line 1217, in __call__
    renpy.python.py_exec_bytecode(self.code.bytecode, locals=scope)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\python.py", line 1297, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/screens.rpy", line 506, in <module>
    $ playing = musictitles[playing]
KeyError: 'music/pause.wav'

Windows-post2008Server-6.2.9200
Ren'Py 6.15.4.320
It was working fine until I boosted the screen resolution.

Any help would be greatly appreciated.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Bug with on-screen music title

#2 Post by PyTom » Tue Jun 04, 2013 11:40 pm

This doesn't look like a bug in Ren'Py. Rather, it seems that you're just getting unlucky, and updating the screen when pause.wav is playing. That's not in musictitles, and hence you're getting the crash.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

clannadman

Re: Bug with on-screen music title

#3 Post by clannadman » Wed Jun 05, 2013 4:21 pm

PyTom wrote:This doesn't look like a bug in Ren'Py. Rather, it seems that you're just getting unlucky, and updating the screen when pause.wav is playing. That's not in musictitles, and hence you're getting the crash.
I don't think it's pause.wav in particular. I get the error with the music track too. It varies between the two

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 77, in script
  File "game/screens.rpy", line 506, in python
KeyError: 'music/jechantes.mp3'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\execution.py", line 288, in run
    node.execute()
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\ast.py", line 453, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\exports.py", line 757, in say
    who(what, interact=interact)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\character.py", line 795, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\character.py", line 671, in do_display
    **display_args)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\character.py", line 474, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\ui.py", line 237, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 1853, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 2092, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 252, in visit_all
    callback(self)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\core.py", line 2092, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\screen.py", line 166, in per_interact
    self.update()
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\display\screen.py", line 266, in update
    self.screen.function(**self.scope)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\screenlang.py", line 1217, in __call__
    renpy.python.py_exec_bytecode(self.code.bytecode, locals=scope)
  File "C:\Users\Anon\Downloads\renpy-6.14.1-sdk\renpy-6.14.1-sdk\renpy\python.py", line 1297, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/screens.rpy", line 506, in <module>
    $ playing = musictitles[playing]
KeyError: 'music/jechantes.mp3'

Windows-post2008Server-6.2.9200
Ren'Py 6.15.4.320
 

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Bug with on-screen music title

#4 Post by PyTom » Wed Jun 05, 2013 8:48 pm

Well, sure - but look at:

Code: Select all

$ musictitles = {"music/jechantes.mp3":("Je Chantes","#00FF00",20)}
$ musictitles = {"music/fat girl.mp3":("Fat Girl","#00FF00",20)}
That's not right - you're creating a dictionary, and immediately replacing it with a second dictionary. You likely want:

Code: Select all

$ musictitles = {
    "music/jechantes.mp3" : ("Je Chantes", "#00FF00", 20),
    "music/fat girl.mp3": ("Fat Girl", "#00FF00", 20),
    }
So you have just one dict created. (You'll still have to deal with the pause problem.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

clannadman

Re: Bug with on-screen music title

#5 Post by clannadman » Thu Jun 06, 2013 4:48 pm

Thank you. Sorry, I seem to be making lots of dumb little mistakes recently.

Post Reply

Who is online

Users browsing this forum: No registered users