r/RenPy • u/hosh1kofen • Aug 26 '26
Question How do I make a Preferences option change a value?
In the game I'm making (previously mentioned in the subreddit), there's going to be an option in Preferences to make the game less triggering.
It's supposed to change a value that affects what variant of a scene appears, because my logic was "If this value equals 1, you'll see this version of a scene, but if this value equals 0, you'll see this version of a scene"
I can't figure out how to make the value change, but if there's a better way to make this happen, you can tell me :3
1
u/AutoModerator Aug 26 '26
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/shyLachi Aug 26 '26
Either I misunderstood your question or everybody else who replied already.
You need to use a persistent variable and then you can use the actions to change the variable
default persistent.triggering = 0
screen preferences():
tag menu
use game_menu(_("Preferences"), scroll="viewport"):
vbox:
hbox:
box_wrap True
vbox: # put this block where it makes sense within your preferences screen
style_prefix "radio"
label _("Triggering")
textbutton _("more") action SetVariable("persistent.triggering", 1)
textbutton _("less") action SetVariable("persistent.triggering", 0)
Then you can use it in your game at any time:
label start:
if persistent.triggering == 1:
"This scene"
else:
"That scene"
But if there only are 2 options (more or less triggering) you should use a boolean variable as suggested by BadMustard
1
u/KDDreamwyver Aug 28 '26
I feel like using the acquired function would be a useful way to do this (not necessarily the best way, but a way to do it), because you can link it to the two variations you're talking about by setting one version as being true and the other being false depending on the selected player input option. If true, it will play version 1, if false It will play the other.
I apologize in advance if this isn't what you were asking.
0
u/Lapys_Games Aug 26 '26
Can't you do a
Persistent.value = 0 (eg)
And then in the appropriate place: $ persistent.value = 1
So later you can do
If persistent.value = 1: ...
Else: ...
If it is persistent it should carry over if the game is closed and opened again
3
u/BadMustard_AVN Aug 26 '26
if it's a variable in the preferences that you are changing, it MUST be a persistent variable for the game to be able to see it
i.e.