Script to prevent input to instantly make text appear.
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.
- dragondatingsim
- Regular
- Posts: 103
- Joined: Sat Feb 14, 2015 10:22 am
- Tumblr: angelswithscalywings
- Contact:
Script to prevent input to instantly make text appear.
Is there a way to prevent user input (click, space, etc) to instantly make text appear when it is set to a certain cps?
I have searched around and found various scripts trying to tackles this particular problem, for example the scripts in this thread:
viewtopic.php?f=8&t=32309
Ultimately, I haven't been able to utilize this in the way I want it to - namely to have a sequence of text appearing at a certain cps rate set to music without the player being able to click to make the text appear instantly (as that desyncs the sequence).
It might be enough to just disable all user input altogether throughout this sequence, but I haven't been able to use this with the scripts in the above thread either, as using no wait tags in the text caused the script to not work as intended.
Maybe the script isn't suited to this task or I'm just doing something horribly wrong. Any ideas?
I have searched around and found various scripts trying to tackles this particular problem, for example the scripts in this thread:
viewtopic.php?f=8&t=32309
Ultimately, I haven't been able to utilize this in the way I want it to - namely to have a sequence of text appearing at a certain cps rate set to music without the player being able to click to make the text appear instantly (as that desyncs the sequence).
It might be enough to just disable all user input altogether throughout this sequence, but I haven't been able to use this with the scripts in the above thread either, as using no wait tags in the text caused the script to not work as intended.
Maybe the script isn't suited to this task or I'm just doing something horribly wrong. Any ideas?
- dragondatingsim
- Regular
- Posts: 103
- Joined: Sat Feb 14, 2015 10:22 am
- Tumblr: angelswithscalywings
- Contact:
Re: Script to prevent input to instantly make text appear.
I'll bump this. At this point I'd be willing to pay someone to solve this problem. It seems like it should be a trivial thing to do, to just be able to disable input for some time since it happens plenty of times in other games, but apparently it's very much impossible in Ren'Py 
- papiersam
- Veteran
- Posts: 231
- Joined: Fri Aug 12, 2016 2:24 pm
- Completed: Gem Hunt Beta, 1/Probably, Animunch
- Projects: The Panda Who Dreamed
- Contact:
Re: Script to prevent input to instantly make text appear.
I think I've got an idea on how to do this--screens and and python and pauses and the like. I'll compile a testable version when I can and post it here for you when it's done.
- papiersam
- Veteran
- Posts: 231
- Joined: Fri Aug 12, 2016 2:24 pm
- Completed: Gem Hunt Beta, 1/Probably, Animunch
- Projects: The Panda Who Dreamed
- Contact:
Re: Script to prevent input to instantly make text appear.
So, after an extensive trial-and-error, I've come to the conclusion that disabling input isn't going to stop the text from instantly appearing. It stops it from advancing, but I guess it still reads the input event and causes the text to complete its action prematurely.
Given this, I'll assume that there's no easy solution. I can build a sort of hack using 'extend' and manipulating the autoforward while disabling input, which would hopefully give a similar effect, but it's only just theory. I'd need to know first, though, if that would be something that you would want, or if you would rather resign to a clever use of ATL transform.
Given this, I'll assume that there's no easy solution. I can build a sort of hack using 'extend' and manipulating the autoforward while disabling input, which would hopefully give a similar effect, but it's only just theory. I'd need to know first, though, if that would be something that you would want, or if you would rather resign to a clever use of ATL transform.
- SundownKid
- Lemma-Class Veteran
- Posts: 2299
- Joined: Mon Feb 06, 2012 9:50 pm
- Completed: Icebound, Selenon Rising Ep. 1-2
- Projects: Selenon Rising Ep. 3-4
- Organization: Fastermind Games
- Deviantart: sundownkid
- Location: NYC
- Contact:
Re: Script to prevent input to instantly make text appear.
What I suggested to him personally was to use a screen + ATL instead since he wanted to use this for the credits sequence and nowhere else, where there are better ways to do the same thing. (e.g. A scrolling screen full of text and then a hard pause)
- dragondatingsim
- Regular
- Posts: 103
- Joined: Sat Feb 14, 2015 10:22 am
- Tumblr: angelswithscalywings
- Contact:
Re: Script to prevent input to instantly make text appear.
It's not the credit sequence itself, but rather the last thing that is seen before the credits.SundownKid wrote:What I suggested to him personally was to use a screen + ATL instead since he wanted to use this for the credits sequence and nowhere else, where there are better ways to do the same thing. (e.g. A scrolling screen full of text and then a hard pause)
Yep, most other solutions that I've found and tried involve disabling input via a screen and result in the same thing - advancing becomes impossible, but the text can still be made to appear instantly by clicking.r_sami wrote:So, after an extensive trial-and-error, I've come to the conclusion that disabling input isn't going to stop the text from instantly appearing. It stops it from advancing, but I guess it still reads the input event and causes the text to complete its action prematurely.
In the end, what I was trying to do is to have text appearing slowly letter by letter in NVL mode. This is set to music and making the text appear instantly by clicking desyncs the sequence.r_sami wrote: Given this, I'll assume that there's no easy solution. I can build a sort of hack using 'extend' and manipulating the autoforward while disabling input, which would hopefully give a similar effect, but it's only just theory. I'd need to know first, though, if that would be something that you would want, or if you would rather resign to a clever use of ATL transform.
Any way that would achieve the same effect would be fine with me. Personally, I haven't really dealt with ATL much before (when it comes to text), so I have no idea if/how that would work.
- papiersam
- Veteran
- Posts: 231
- Joined: Fri Aug 12, 2016 2:24 pm
- Completed: Gem Hunt Beta, 1/Probably, Animunch
- Projects: The Panda Who Dreamed
- Contact:
Re: Script to prevent input to instantly make text appear.
I have a roundabout way to do that, then:In the end, what I was trying to do is to have text appearing slowly letter by letter in NVL mode. This is set to music and making the text appear instantly by clicking desyncs the sequence.
Code: Select all
screen tsetup:
timer 0.1 action Preference("auto-forward", "enable") repeat False
key "K_RETURN" action NullAction()
key "K_KP_ENTER" action NullAction()
key "K_SPACE" action NullAction()
key "mousedown_4" action NullAction()
key "K_PAGEUP" action NullAction()
key "mousedown_5" action NullAction()
key "K_PAGEDOWN" action NullAction()
key "mouseup_3" action NullAction()
key "mouseup_1" action NullAction()
key "K_ESCAPE" action NullAction
key "mouseup_3" action NullAction()
key "mouseup_1" action NullAction()
screen returnset:
timer 0.1 action Preference("auto-forward", "disable") repeat False
define nnvl = Character(None, kind=nvl)
label start:
"normal text"
show screen tsetup
$config.default_afm_time = 0.1
window show
nnvl "h"
extend "e"
extend "l"
extend "l"
extend "o"
extend " "
extend "w"
extend "o"
extend "r"
extend "l"
extend "d"
hide screen tsetup
$renpy.pause(1.0, hard=True)
show screen returnset #as I cant seem to find a way to turn off autoforward with just a python statement, but I'm probably just overlooking something
pause 0.5 #needs at least 0.1 seconds to turn off autoforward
window hide
nvl clear
hide screen returnset
"back to normal"
I think this accomplishes that fairly.In the end, what I was trying to do is to have text appearing slowly letter by letter in NVL mode.
In any case, I hope this helps.
- dragondatingsim
- Regular
- Posts: 103
- Joined: Sat Feb 14, 2015 10:22 am
- Tumblr: angelswithscalywings
- Contact:
Re: Script to prevent input to instantly make text appear.
While the test script does work as it is, longer sentences just cause it to freeze eventually. Inputs that aren't deactivated by the screen still work at that point, but the script does not progress anymore.
Thanks for trying, though!
Thanks for trying, though!
- papiersam
- Veteran
- Posts: 231
- Joined: Fri Aug 12, 2016 2:24 pm
- Completed: Gem Hunt Beta, 1/Probably, Animunch
- Projects: The Panda Who Dreamed
- Contact:
Re: Script to prevent input to instantly make text appear.
Weird. I tested it again with over 500 characters:longer sentences just cause it to freeze eventually. Inputs that aren't deactivated by the screen still work at that point, but the script does not progress anymore.
Code: Select all
$i = 500
window show
nnvl "h"
while i > 0:
extend "c"
if i%5:
extend " " #needs spaces
$i-=1
- dragondatingsim
- Regular
- Posts: 103
- Joined: Sat Feb 14, 2015 10:22 am
- Tumblr: angelswithscalywings
- Contact:
Re: Script to prevent input to instantly make text appear.
I've tried it with your script and also just pasted it into a completely new project with the same result. My best guess is that it might be related to lower-end computers, in which case it probably wouldn't be a good idea to implement it like that in a game :/
- papiersam
- Veteran
- Posts: 231
- Joined: Fri Aug 12, 2016 2:24 pm
- Completed: Gem Hunt Beta, 1/Probably, Animunch
- Projects: The Panda Who Dreamed
- Contact:
Re: Script to prevent input to instantly make text appear.
I tested it on my old computer, with a processing power lower than that of the average smartphone, and it ran just as expected. It's running an older version of Renpy, so there's no issue there either.My best guess is that it might be related to lower-end computers
Maybe it's just your current configuration of Renpy? Other than that, I don't know what the problem is.
Re: Script to prevent input to instantly make text appear.
A video.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.
10 ? "RENPY"
20 GOTO 10
RUN
10 ? "RENPY"
20 GOTO 10
RUN
- papiersam
- Veteran
- Posts: 231
- Joined: Fri Aug 12, 2016 2:24 pm
- Completed: Gem Hunt Beta, 1/Probably, Animunch
- Projects: The Panda Who Dreamed
- Contact:
Re: Script to prevent input to instantly make text appear.
As an alternative? I suppose it would work. But in that case, ATL is better-more configurable and all.A video.
- dragondatingsim
- Regular
- Posts: 103
- Joined: Sat Feb 14, 2015 10:22 am
- Tumblr: angelswithscalywings
- Contact:
Re: Script to prevent input to instantly make text appear.
Well, after a few more hours of messing around, I'm not much wiser in regards to my earlier problem with the script. I tested it out on an old laptop, and while the game runs slow, the script does not freeze up on it as it does on my main computer.
I have also tried re-downloading ren'py in case there was some corruption, but the problem still persists. Just recording the relevant section and playing it back as a video does seem like the easiest option by this point, unless anyone has any better ideas.
I have also tried re-downloading ren'py in case there was some corruption, but the problem still persists. Just recording the relevant section and playing it back as a video does seem like the easiest option by this point, unless anyone has any better ideas.
- papiersam
- Veteran
- Posts: 231
- Joined: Fri Aug 12, 2016 2:24 pm
- Completed: Gem Hunt Beta, 1/Probably, Animunch
- Projects: The Panda Who Dreamed
- Contact:
Re: Script to prevent input to instantly make text appear.
After a bit of thought, I figured, "Why not use screen timers and for loops?". This is the result:
It doesn't use NVL and it requires a but more specific customisation for longer strings, but it might be a better solution than the auto-forward trick.
Hope this helps.
Code: Select all
screen sc(qq):
timer 1.0 repeat True action If(qw < len(qq), true=SetVariable('qw', qw+1), false=NullAction())
for i in range (0, qw):
$m = qq[i] #needs to be done to avoid str not indices error
$yp = 300
#$xp = 40
text "[m]" pos i*40+10, yp #pos can be changed for each letter
#$xp += 50
#if i == 10:
#yp += 50
#$xp = 50 #clause for longer sentences
label start:
"normal text"
$qw = 0
show screen sc(list("hello world")) #replace hello world with text
$renpy.pause((len(list("hello world"))+1), hard=True) #gets the assumed length of time it will take, plus any time for the whole message to be displayed (needs to be tweaked if the cps speed is faster than 1 char per second)
hide screen sc
"done"
Hope this helps.
Who is online
Users browsing this forum: CharlieFuu69, Google [Bot], Ocelot

