Custom Preference in Screen Language [Solved]
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.
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.
- Aleema
- Lemma-Class Veteran
- Posts: 2677
- Joined: Fri May 23, 2008 2:11 pm
- Organization: happyB
- Tumblr: happybackwards
- Contact:
Custom Preference in Screen Language [Solved]
Dumb question time.
The switch to SL seems like it would be perfect for adding whatever we want to game menus, since having a custom preference option wasn't possible with imagemap layouts before.
Thing is, I'm stupid, and I can't figure out how to add a custom preference option to the preferences screen that isn't hard coded in.
What actions should I implement for this to happen, so I could have an option to turn off mini-games, for example?
Is it possible? Because I'm looking at the guts of Ren'Py, and the "preferences constructor" looks pretty hard coded to not accept anything but what's there ...
The switch to SL seems like it would be perfect for adding whatever we want to game menus, since having a custom preference option wasn't possible with imagemap layouts before.
Thing is, I'm stupid, and I can't figure out how to add a custom preference option to the preferences screen that isn't hard coded in.
What actions should I implement for this to happen, so I could have an option to turn off mini-games, for example?
Is it possible? Because I'm looking at the guts of Ren'Py, and the "preferences constructor" looks pretty hard coded to not accept anything but what's there ...
Last edited by Aleema on Sun Jan 30, 2011 10:10 am, edited 1 time in total.
- jack_norton
- Lemma-Class Veteran
- Posts: 4096
- Joined: Mon Jul 21, 2008 5:41 pm
- Completed: Too many! See my homepage
- Projects: A lot! See www.winterwolves.com
- Tumblr: winterwolvesgames
- Contact:
Re: Custom Preference in Screen Language
I did that on PS to change layout and add the "difficulty" setting in the options, but it's no use posting the code here since is a total hack. I'd like to see (whenever pytom has time of course) some tutorials about doing this the "official way". Another option I wanted to use is "delete savegame" option in the load/save, but since I had fear of deleting users wrong files I gave up on this one
Re: Custom Preference in Screen Language
Aleema // Well, there's ToggleVariable or SetVariable action and I think you can simply add it to your preference screen.
Anyway I didn't test it so I'm not sure it would work with your minigame code.
Code: Select all
init:
screen preference:
#....
has vbox
text 'Do you want to do Mini-Games?'
hbox:
textbutton 'Yes' action SetVariable('minigame', True)
textbutton 'No' action SetVariable('minigame', False)
#...
label minigame:
if not minigame:
return
else:
# ....
- Aleema
- Lemma-Class Veteran
- Posts: 2677
- Joined: Fri May 23, 2008 2:11 pm
- Organization: happyB
- Tumblr: happybackwards
- Contact:
Re: Custom Preference in Screen Language
Oh, the variable has to be in quotes? I saw that action and tried it, got some string error, so I guess that was the original problem. Thanks, it worked.
Next problem: preferences should be persistent so you don't have to set them every time. I replaced a generic variable with this:
Got:
Tell me I'm just being stupid again. >_<
Next problem: preferences should be persistent so you don't have to set them every time. I replaced a generic variable with this:
Code: Select all
textbutton _("Yes") action SetVariable('persistent.stopjukebox', True)
Code: Select all
AttributeError: 'module' object has no attribute 'persistent.stopjukebox'
- jack_norton
- Lemma-Class Veteran
- Posts: 4096
- Joined: Mon Jul 21, 2008 5:41 pm
- Completed: Too many! See my homepage
- Projects: A lot! See www.winterwolves.com
- Tumblr: winterwolvesgames
- Contact:
Re: Custom Preference in Screen Language
That's the problem I had, I used a Class to set my variable (wasn't a persistent one though)
Re: Custom Preference in Screen Language
Ah... Try using SetFeild.
Code: Select all
init:
$ persistent.stopjukebox = '1'
screen test:
hbox:
textbutton "Yes" action SetField(persistent, 'stopjukebox', True)
textbutton "No" action SetField(persistent, 'stopjukebox', False)
textbutton "return" action Return()
label start:
call screen test
if persistent.stopjukebox:
#...
else:
# ....
- Aleema
- Lemma-Class Veteran
- Posts: 2677
- Joined: Fri May 23, 2008 2:11 pm
- Organization: happyB
- Tumblr: happybackwards
- Contact:
Re: Custom Preference in Screen Language
It worked!!
Thank you very much! You sure know your way around SL.
Thank you very much! You sure know your way around SL.
- octacon100
- Regular
- Posts: 163
- Joined: Thu Sep 12, 2013 11:23 pm
- Projects: Regeria Hope
- Organization: Golden Game Barn
- IRC Nick: Octacon100
- Location: Boston, MA
- Contact:
Re: Custom Preference in Screen Language [Solved]
I know I'm necro'ing the heck out of this topic, but it's extremely useful for anyone wanting to add their own preferences. I'd volunteer to write a page about this in the Ren'py online documentation from this post if people wanted it.
-
- Regular
- Posts: 93
- Joined: Mon Dec 30, 2013 1:55 am
- Projects: Project Bluefield - Origins
- Organization: Autumn Rain
- Deviantart: playerzero17
- itch: autumn-rain
- Contact:
Re: Custom Preference in Screen Language [Solved]
I'd really appreciate it...octacon100 wrote: ↑Wed Feb 04, 2015 9:27 pm I know I'm necro'ing the heck out of this topic, but it's extremely useful for anyone wanting to add their own preferences. I'd volunteer to write a page about this in the Ren'py online documentation from this post if people wanted it.
Who is online
Users browsing this forum: No registered users