Page 1 of 1

Setting variable as another variable (solved)

Posted: Fri Jan 11, 2019 4:41 am
by Smaymay
Hi there, I'm coding the point system at the moment to determine which character the player will end up with. Of course, there are also scenes for the possibility that you end up with a tie. The system works fine at the moment except for one tiny detail.

Code: Select all

if tiedBetweenTwo == True:
        show choiceOverlay
        menu:
            "[tiedBoy1]":
                hide choiceOverlay
                $ boyChoice = "[tiedBoy1]"
                $ renpy.fix_rollback()
                MC "[tiedBoy1]?"
                MC "Of course!"
            "[tiedBoy2]":
                hide choiceOverlay
                $ boyChoice = "[tiedBoy2]"
                $ renpy.fix_rollback()
                MC "[tiedBoy2]?"
                MC "Of course!"
The game will fill in the right name for those tiedBoy variables used in the dialogue. But when I try to use the boyChoice variable...

Code: Select all

MC "[boyChoice], you will be mine!"
This will just print out [boyChoice] instead of the name set to one of the tiedBoy variables.

I was wondering if it's possible at all to set a variable as another variable. But this could be a syntax error on my part after all! Thanks in advance :)

Re: Setting variable as another variable

Posted: Fri Jan 11, 2019 5:09 am
by philat
$ boyChoice = tiedBoy1

Re: Setting variable as another variable

Posted: Fri Jan 11, 2019 7:46 am
by Smaymay
@philat

Oh damn. It works haha. I feel so dumb. Thanks for the quick reply. Learned something new today ^^

Re: Setting variable as another variable (solved)

Posted: Fri Jan 11, 2019 9:25 am
by philat
No problem. Interpolation (in whatever form you may come across, .format() or % or []) is only necessarily when you want to put the variable in a STRING. In all other contexts, it's just the variable name.