Variables inside variables???!!!

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
gaoldart
Regular
Posts: 36
Joined: Wed Jul 06, 2011 11:23 am
Projects: Tony T (Writer, programmer)
Location: Under your chair >8D
Contact:

Variables inside variables???!!!

#1 Post by gaoldart »

In my series of "A n00b shouldn't ask such questions!!!!!" threads, i ask:

Is it possible to create a variable thanks to othe variables?

so... let's say i do something like this:

Code: Select all

    $ persistent.ending_1 = None
    $ persistent.ending_2 = None
    $ persistent.ending_3 = None
    $ persistent.true = None
At the beggining, and i want to change the main menu after the three endings are achieved, so i put something like:

Code: Select all

    if persistent.ending_1, persistent.ending_2, persistent.ending_3:
        "true_background.jpg"
    else:
        "lame_background.jpg"
If so... is it possible to unlock a variable thanks to other variables?

Like:

Code: Select all

    if persistent.ending_1, persistent.ending_2, persistent.ending_3:
        persistent.true = True
Because if it is possible, that would allow me to save some time in programming.
Bashing my head against the computer desk while programming since march 2011, and so far no brain damashii nanananananananana katamari damashii

Anima
Veteran
Posts: 448
Joined: Wed Nov 18, 2009 11:17 am
Completed: Loren
Projects: PS2
Location: Germany
Contact:

Re: Variables inside variables???!!!

#2 Post by Anima »

Code: Select all

    $ persistent.ending_1 = False
    $ persistent.ending_2 = False
    $ persistent.ending_3 = False
    $ persistent.true = False

Code: Select all

    if persistent.ending_1 and persistent.ending_2 and persistent.ending_3:
        $ persistent.true = True

Code: Select all

    if persistent.true:
        "true_background.jpg"
    else:
        "lame_background.jpg"
Like this?
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase III

gaoldart
Regular
Posts: 36
Joined: Wed Jul 06, 2011 11:23 am
Projects: Tony T (Writer, programmer)
Location: Under your chair >8D
Contact:

Re: Variables inside variables???!!!

#3 Post by gaoldart »

Yup, who could guess. It worked!!
Bashing my head against the computer desk while programming since march 2011, and so far no brain damashii nanananananananana katamari damashii

Post Reply

Who is online

Users browsing this forum: No registered users