[solved] ToggleScreenVariable in nested screens

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
User avatar
Kia
Miko-Class Veteran
Posts: 922
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Skype: KiaAzad
Contact:

[solved] ToggleScreenVariable in nested screens

#1 Post by Kia » Thu Jan 03, 2019 3:04 am

I've found this gives me and error:

Code: Select all

screen nested_test:
    use nested_in

screen nested_in:
    default ylg = 1.0
    button:
        action ToggleScreenVariable("ylg", 0.0, 1.0)
        yalign ylg
        text "jump"

label start:
    show screen nested_test
    pause
    
    return
here's the error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 13, in script
    pause
  File "renpy/common/000statements.rpy", line 416, in execute_pause
    renpy.pause()
  File "renpy/common/00action_data.rpy", line 356, in __call__
    value = cs.scope[self.name]
KeyError: u'ylg'
it doesn't happen when the screen is called directly or when I'm using "SetScreenVariable" instead
Last edited by Kia on Sun Jan 13, 2019 7:59 am, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 15481
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: [bug] ToggleScreenVariable in nested screens

#2 Post by PyTom » Sat Jan 12, 2019 5:07 pm

Checkout ToggleLocalVariable and SetLocalVariable if you want to access variables in nested screens. (These are slower than their ScreenVariable equivalents.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Kia
Miko-Class Veteran
Posts: 922
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Skype: KiaAzad
Contact:

Re: [solved] ToggleScreenVariable in nested screens

#3 Post by Kia » Sun Jan 13, 2019 8:01 am

I can't believe the solution was in front of my eyes the whole time, I need to pay attention to the changes.
thank you ^_^

Post Reply

Who is online

Users browsing this forum: No registered users