Is there a way to toggle Auto-Forward?
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.
-
- Regular
- Posts: 70
- Joined: Sun Jul 15, 2007 2:36 pm
- Projects: EH...
- Contact:
Is there a way to toggle Auto-Forward?
As someone who prefers to save myself from additional repetitive finger strain, I greatly appreciate having an auto-forward option in visual novels. I see that Ren'Py allows the user to change the speed of auto-forward (with the maximum setting stopping it entirely), but I was wondering: Is there a way to toggle it on and off...perhaps with a keystroke? It seems rather annoying to have to go into the preferences menu to adjust the slider each time I want to start and stop.
Re: Is there a way to toggle Auto-Forward?
AFM is coded rather terribly in Ren'Py by default. It's possible to code around it (I did it in KS), but it's not a one-liner.
The rest is left as an exercise for the reader.
-
- Eileen-Class Veteran
- Posts: 1265
- Joined: Fri Aug 31, 2007 7:02 am
- Projects: 0 completed game. Still haven't made any meaningfully completed games...
- Contact:
Re: Is there a way to toggle Auto-Forward?
You can use ui.keymap in an overlay like so:@berration wrote:Is there a way to toggle it on and off...perhaps with a keystroke?
Code: Select all
init python:
def afm_overlay():
ui.keymap(A=ui.callsinnewcontext("toggle_afm")) #This keymap uses A. You can choose your own keymap.
config.overlay_functions.append(afm_overlay)
label toggle_afm:
if _preferences.afm_time== 0:
$ _preferences.afm_time= 1 #Set to whatever speed you want
elif _preferences.afm_time> 0:
$ _preferences.afm_time=0
return
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.
- PyTom
- Ren'Py Creator
- Posts: 16093
- 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: Is there a way to toggle Auto-Forward?
A better way to toggle afm is:
Code: Select all
init python:
_preferences.afm_enable = False
if not persistent.set_afm:
_preferences.afm_time = 10 # Or something.
persistent.set_afm = True
def toggle_afm():
_preferences.afm_enable = not _preferences.afm_enable
renpy.restart_interaction()
def afm_woc():
if _preferences.afm_enable:
ui.textbutton("Auto", role="selected_", clicked=toggle_afm)
else:
ui.textbutton("Auto", clicked=toggle_afm)
config.window_overlay_callbacks.append(afm_woc)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
-
- Regular
- Posts: 70
- Joined: Sun Jul 15, 2007 2:36 pm
- Projects: EH...
- Contact:
Re: Is there a way to toggle Auto-Forward?
Ah, fantastic! I'd prefer not to force the user to always switch to whatever arbitrary speed I pick, but that should be easy easy enough to fix by saving the previous preference setting (if it exists) in a variable, and grabbing it from there. That much code, hopefully, I should be able to manage on my own.JQuartz wrote:You can use ui.keymap in an overlay like so:
Thanks a lot!
...
...Heh. Or I can just wait another minute or two for PyTom to do it for me.
Hmm, that one's going to take me a little bit longer for me to understand, but I appreciate it. I'll give it a shot.
Thanks!
--
Update: Okay, I tried this out... but I got this error:
Code: Select all
Exception: config.window_overlay_callbacks is not a known configuration variable.
While executing init code:
- script at line 67 of C:\Renpy\Projects\Test Game/game/script.rpy
- python at line 84 of C:\Renpy\Projects\Test Game/game/script.rpy.
-- Full Traceback ------------------------------------------------------------
File "C:\Renpy\RenPy 6.10.1\renpy\bootstrap.py", line 260, in bootstrap
File "C:\Renpy\RenPy 6.10.1\renpy\main.py", line 255, in main
File "C:\Renpy\RenPy 6.10.1\renpy\execution.py", line 230, in run
File "C:\Renpy\RenPy 6.10.1\renpy\ast.py", line 557, in execute
File "C:\Renpy\RenPy 6.10.1\renpy\python.py", line 928, in py_exec_bytecode
File "C:\Renpy\Projects\Test Game/game/script.rpy", line 84, in <module>
File "C:\Renpy\RenPy 6.10.1\renpy\store.py", line 66, in __getattr__
Exception: config.window_overlay_callbacks is not a known configuration variable.
Re: Is there a way to toggle Auto-Forward?
I dunno if it helps, but you can implement PyTom's code to other buttons; for example, my ui.imagebuttons.
You probably can do the same for ui.textbuttons and such.
Actually I have a related question to this. The toggle on/off works beautifully; however I set the speed to 10 as indicated in the example, but my text goes lightning fast til I go into preferences and adjust the speed myself(in the preferences screen it is indeed set to 10. edit: actually, it displays no value(empty bar) no matter what value I write down for afm speed.). I tried changing the _preferences.afm_time value, but the speed displayed is the same.
Code: Select all
def outside_button():
if show_outside_button:
if _preferences.afm_enable:
ui.imagebutton("imagebu/afw1.png","imagebu/afw2.png",xalign=0.425, yalign=0.99, role="selected_",clicked=toggle_afm)
else:
ui.imagebutton("imagebu/afw1.png","imagebu/afw2.png",xalign=0.425, yalign=0.99, clicked=toggle_afm)
config.overlay_functions.append(outside_button)
Actually I have a related question to this. The toggle on/off works beautifully; however I set the speed to 10 as indicated in the example, but my text goes lightning fast til I go into preferences and adjust the speed myself(
Last edited by aoarashit on Sat Jan 02, 2010 10:59 pm, edited 1 time in total.
- PyTom
- Ren'Py Creator
- Posts: 16093
- 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: Is there a way to toggle Auto-Forward?
The code I gave above will set it once, and then leave it up to the user to set. If you want Ren'Py to set it twice, you'll have to clear persistent.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: Is there a way to toggle Auto-Forward?
I cleared persistent all the time I fixed the speed. Seems to be the same no matter what I put...
Quite weird, since it worked fine the first time around when I just used just
alone as an experiment.
After I put in the else and if, the text started forwarding fast. Like I said, I deleted persistent every time. I erased the else and if and tried one more time, and now the text speed does not seem to be working either @_@ Must have mad a major screwup somewhere.
+added: Solved.
I either put
1.
if not persistent.set_afm_time:
_preferences.afm_time = 10
persistent.set_afm_time = True
(added in _time for the first and third line, from cookbook)
or
2. or deleted all afm codes, set persistent.set_afm_time=False and deleted persistent.(according to JQuartz's reply to an old thread)
Glad I got that out of my mind
Quite weird, since it worked fine the first time around when I just used just
Code: Select all
ui.imagebutton("imagebu/afw1.png","imagebu/afw2.png",xalign=0.425, yalign=0.99, clicked=toggle_afm
After I put in the else and if, the text started forwarding fast. Like I said, I deleted persistent every time. I erased the else and if and tried one more time, and now the text speed does not seem to be working either @_@ Must have mad a major screwup somewhere.
+added: Solved.
I either put
1.
if not persistent.set_afm_time:
_preferences.afm_time = 10
persistent.set_afm_time = True
(added in _time for the first and third line, from cookbook)
or
2. or deleted all afm codes, set persistent.set_afm_time=False and deleted persistent.(according to JQuartz's reply to an old thread)
Glad I got that out of my mind
Who is online
Users browsing this forum: AWizardWithWords, Ocelot, piinkpuddiin