[Solved] Changing values of variables with a screen action

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
Chekhov
Regular
Posts: 113
Joined: Tue Jun 26, 2018 9:19 am
Projects: Pluton
Contact:

[Solved] Changing values of variables with a screen action

#1 Post by Chekhov »

I've been trying to get a better grip on the screen language. What is the right way to use screens to change a variable?

Something like

Code: Select all

textbutton _("hide nudity") action SetVariable(persistent.nudity_, "off")
doesn't work. Because persistent values aren't just strings. Any ideas on how to resolve this smartly?
I've ran into the same problem when I wanted to change integer values. I feel like I'm missing something obvious.

Code: Select all

AttributeError: 'NoneType' object has no attribute 'rpartition'
https://www.renpy.org/doc/html/screen_a ... on#actions
Last edited by Chekhov on Fri Nov 19, 2021 6:56 pm, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Changing values of variables with a screen action

#2 Post by Ocelot »

First argument to SetVariable is name of the variable, not the vairable itself. SetVariable("hours", 5)
The `name` argument must be a string, and can be a simple name like "strength", or
one with dots separating the variable from fields, like "hero.strength"
or "persistent.show_cutscenes".[/qoute]
< < insert Rick Cook quote here > >

User avatar
Chekhov
Regular
Posts: 113
Joined: Tue Jun 26, 2018 9:19 am
Projects: Pluton
Contact:

Re: Changing values of variables with a screen action

#3 Post by Chekhov »

Ocelot wrote: Fri Nov 19, 2021 6:50 pm First argument to SetVariable is name of the variable, not the vairable itself. SetVariable("hours", 5)
The `name` argument must be a string, and can be a simple name like "strength", or
one with dots separating the variable from fields, like "hero.strength"
or "persistent.show_cutscenes".[/qoute]
Lmao, okay, I should have asked this weeks ago.

Thank you dude.

Post Reply

Who is online

Users browsing this forum: Alex, Google [Bot]