[Solved] Creating displayable character element with ToggleVariable

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
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

[Solved] Creating displayable character element with ToggleVariable

#1 Post by kostek00 »

I'm creating character gallery where user can pick body, face emotion and other stuff to show. I'm stuck with ToggleVariable to add and remove from sprite. It throws me error "The variable other does not exist."

I do have it created in screen?:

Code: Select all

default blush = None
This is button to toggle it:

Code: Select all

textbutton "BLUSH":
                        text_style "page_text"
                        style "page_textbutton"

                        if body is not "blush_image":
                            hovered Play("system",guisfx_button_hover)
                        action [Play("system",guisfx_button_click),
                                SelectedIf(blush=="blush_image"),
                                ToggleVariable("blush", true_value="blush_image", false_value=False)]

                        at gui_buttonfade
Last edited by kostek00 on Wed Apr 10, 2019 2:30 pm, edited 1 time in total.

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Creating displayable character element with ToggleVariable

#2 Post by Enchant00 »

It's possible you defined your other variable in the wrong place hence the error. If it's alright with you, can you share the code where you defined your other and where it is used. I don't see anywhere in your code where you used the variable so I'm unclear whether it really is a problem with your toggle variable.

User avatar
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

Re: Creating displayable character element with ToggleVariable

#3 Post by kostek00 »

Oh wait i forgot i changed all "other" to "blush" so error should be "The variable blush does not exist."

This variable is in the same screen that button is:

Code: Select all

screen cg_page3(page=3):
    tag menu

    default blush = None
It's "None" because by default I don't want it to show "blush" on character.

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Creating displayable character element with ToggleVariable

#4 Post by philat »

Don't define it in the screen (that makes it a screen variable, which is local to the screen, rather than a regular, global variable).

User avatar
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

Re: Creating displayable character element with ToggleVariable

#5 Post by kostek00 »

Oh, that solved the problem. Thank you.

Also I had to change "false_value" to "None" otherwise it was crashing when hiding blush.

Post Reply

Who is online

Users browsing this forum: No registered users