which different between 'play music' and '$renpy.music.play'?

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
wtfman
Regular
Posts: 37
Joined: Sat Mar 30, 2013 7:26 pm
Contact:

which different between 'play music' and '$renpy.music.play'?

#1 Post by wtfman »

As far as I know, ren'py has two ways to play music files. one is play music "filename.ext", another one is $renpy.music.play("filename.ext")...

I wonder which is different between these commands.

may I use anything that is convenient for me?

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: which different between 'play music' and '$renpy.music.play'?

#2 Post by hell_oh_world »

They are pretty much the same, they differ on where you use them. If you're inside a renpy code block where renpy syntax exists, such as when youre inside a label you can use the play command. But when youre inside python where renpy syntax doesnt exist (only native pythonic syntax is allowed) then you use the renpy.music.play function, example would be if youre inside a python: block where multiline python codes are allowed or through $ statement where you are allowed to use single line python syntax. Maybe just remember this... Anything that makes things around renpy easier are pure renpy syntax, such as that play command wherein you wouldnt bother typing renpy.music.play like what is supposed in the python counterpart.

Code: Select all

label start:
  $ renpy.music.play("some.mp3") # $ allows python single statements.
  python:
    play music "some3.mp3" # wont work you told renpy to read lines inside the python: block to run under python... So renpy syntax isn't allowed
  renpy.music.play("some3.mp3") # wont work since you didnt tell renpy to read this line in python. Use $ or python: instead.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], voluorem