How do I properly 'set up' a 'global' preference variable?

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
darksaga
Newbie
Posts: 1
Joined: Sat Jul 20, 2019 1:10 pm
Contact:

How do I properly 'set up' a 'global' preference variable?

#1 Post by darksaga » Sat Jul 20, 2019 1:36 pm

Hello,

I'd like to add a bar value to my preference screen by which the user will control the opacity of the user interface.
The 'linked' preference variable should be persited globally for the whole game, e.g. like the text speed you can adjust on the preference screen, and not persisted in every individual save file.

Somehow I only get this to work properly, when I persist the variable on a 'by save file' basis, using the following bar value methods to access it (global var, object var):

Code: Select all

FieldValue(object, field, range, max_is_zero=False, style=u'bar', offset=0, step=None, action=None)
VariableValue(variable, range, max_is_zero=False, style=u'bar', offset=0, step=None, action=None)
Nonetheless I'd like the preference variable the bar value can access to be save file independant and to be set globally for the game.
I assume it's related to this doc topic: https://www.renpy.org/doc/html/persistent.html or this post: viewtopic.php?t=3514

Can anybody tell me how to do this properly?

Post Reply

Who is online

Users browsing this forum: No registered users