[Solved] Renpy variable in scene command, is possible?

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,692
Could this be done with videos also?
I've tried to do it similarly like this, but it can't find the file:
Code:
$ girlname= "sarah"
image dance = Movie(play="characters/[girlname]/dance.webm")
show dance
I'm not sure and I can't prove it right now, but have you tried it this way?

Code:
$ girlname= "sarah"
play movie "characters/[girlname]/dance.webm" loop
show dance
pause
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,363
15,281
Could this be done with videos also?
No.
When you write something like image myVideo = Movie( play="whatever" ) you are in fact creating an object that will later play the video. And the path to the video is proceeded when you create the object, not when you'll play it. So, it would have no interest to have text substitution here.
Note that it also apply for any , for the exact same reason.

If you really need the movie to have a dynamic name, there's a workaround with :
Code:
default girlname = "sarah"

label whatever:
    [...]
    $ renpy.movie_cutscene( "characters/{}/dance.webm".format( girlname ) )
But it's not suitable for all situation since it will display the movie in full screen, whatever the original size of the movie.

Code:
play movie "characters/[girlname]/dance.webm" loop
Tried it before answering, and it didn't works. But like I don't have use for movies (at least for now), my knowledge on this subject is limited and I can have messed my test.
 
  • Like
Reactions: Porcus Dev

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,667
23,783
Python:
default girlname = ""

image flexmovie = ConditionSwitch(
    "girlname == 'girl name 1'", Movie(play="girl1 movie file"),
    "girlname == 'girl name 2'", Movie(play="girl2 movie file"),
    "girlname == 'girl name 3'", Movie(play="girl3 movie file"),
    "True", Movie(play="your default movie file")
    )
   
label start:

    $ girlname = "girl name 1"
    show flexmovie
    "some important dialogue"
    hide flexmovie
   
    $ girlname = "girl name 3"
    show flexmovie
    "more important dialogue"
    hide flexmovie
being declared at init level as constant, i doubt the displayable will become more variable than that.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
Python:
default girlname = ""

image flexmovie = ConditionSwitch(
    "girlname == 'girl name 1'", Movie(play="girl1 movie file"),
    "girlname == 'girl name 2'", Movie(play="girl2 movie file"),
    "girlname == 'girl name 3'", Movie(play="girl3 movie file"),
    "True", Movie(play="your default movie file")
    )
  
label start:

    $ girlname = "girl name 1"
    show flexmovie
    "some important dialogue"
    hide flexmovie
  
    $ girlname = "girl name 3"
    show flexmovie
    "more important dialogue"
    hide flexmovie
being declared at init level as constant, i doubt the displayable will become more variable than that.
That's exactly how I use/switch between the movies for the male and female MC in my game. I'd search ages and tried several other things, but didn't find any better solution.
Python:
#player can choose between male and female mc at the start of the game

image bjhmovtrd = ConditionSwitch(
    "mcgender == 'woman'", Movie(play="anim/bjhtrd_fem.webm"),
    "True", Movie(play="anim/bjhtrd.webm"))

label start:
    "Choose your gender"
    menu:
        "Male":
            $pcgender = male
            jump somewherelse
        "Female":
            $ pcgender = female
            jump somewherelse
            
label somewherelse:
    scene bjhmovtrd
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,667
23,783
That's exactly how I use/switch between the movies for the male and female MC in my game. I'd search ages and tried several other things, but didn't find any better solution.
Python:
#player can choose between male and female mc at the start of the game

image bjhmovtrd = ConditionSwitch(
    "mcgender == 'woman'", Movie(play="anim/bjhtrd_fem.webm"),
    "True", Movie(play="anim/bjhtrd.webm"))

label start:
    "Choose your gender"
    menu:
        "Male":
            $pcgender = male
            jump somewherelse
        "Female":
            $ pcgender = female
            jump somewherelse
           
label somewherelse:
    scene bjhmovtrd
nice i wasn't completely wrong. :giggle:
 
  • Like
Reactions: recreation