Music.get_playing

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Triority
Regular
Posts: 183
Joined: Fri Jul 20, 2018 1:28 pm
Completed: Welcome To... Chichester 0, 1,2 OVN 1, OVN 2, OVN 3, No Regrets For The Future
Projects: Welcome To... Chichester series
Organization: Triority
Tumblr: Sku-te
itch: triority
Location: England
Discord: sku_te
Contact:

Music.get_playing

#1 Post by Triority »

I'm finding that after using play music "<from xxx>" and then using music.get_playing - the returned music filename also contains the "<from>" text.

Is that supposed to happen ?

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Music.get_playing

#2 Post by gas »

I dunno, but this should return your filename string with the <from..> part stripped out, if you need for.

Code: Select all

$ mytrack = renpy.get_playing()
$ trackname = mytrack.partition(">")[2]
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Triority
Regular
Posts: 183
Joined: Fri Jul 20, 2018 1:28 pm
Completed: Welcome To... Chichester 0, 1,2 OVN 1, OVN 2, OVN 3, No Regrets For The Future
Projects: Welcome To... Chichester series
Organization: Triority
Tumblr: Sku-te
itch: triority
Location: England
Discord: sku_te
Contact:

Re: Music.get_playing

#3 Post by Triority »

You do have to check for ">" before partitioning otherwise there can be run-time errors if it's not present.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Music.get_playing

#4 Post by gas »

Sure, if you want a generical approach.
Even a function returning the name could be used.

Code: Select all

def trackname(what):
    if ">" in what:
        return what.partition(">")[2]
    return what

label idunno:
    $ mytrack = trackname(renpy.get_playing())
(Those are just suppositions, I don't know if there's an internal method to return the spurious track name).
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Triority
Regular
Posts: 183
Joined: Fri Jul 20, 2018 1:28 pm
Completed: Welcome To... Chichester 0, 1,2 OVN 1, OVN 2, OVN 3, No Regrets For The Future
Projects: Welcome To... Chichester series
Organization: Triority
Tumblr: Sku-te
itch: triority
Location: England
Discord: sku_te
Contact:

Re: Music.get_playing

#5 Post by Triority »

Very true

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]