Script to prevent input to instantly make text appear.

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.
Message
Author
User avatar
dragondatingsim
Regular
Posts: 103
Joined: Sat Feb 14, 2015 10:22 am
Tumblr: angelswithscalywings
Contact:

Script to prevent input to instantly make text appear.

#1 Post by dragondatingsim » Fri Jun 10, 2016 6:55 am

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?

User avatar
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.

#2 Post by dragondatingsim » Wed Aug 17, 2016 9:10 am

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 :?

User avatar
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.

#3 Post by papiersam » Wed Aug 17, 2016 9:24 am

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.

User avatar
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.

#4 Post by papiersam » Wed Aug 17, 2016 3:46 pm

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.

User avatar
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.

#5 Post by SundownKid » Wed Aug 17, 2016 4:43 pm

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)

User avatar
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.

#6 Post by dragondatingsim » Thu Aug 18, 2016 5:54 am

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)
It's not the credit sequence itself, but rather the last thing that is seen before the credits.
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.
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: 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.
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.

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.

User avatar
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.

#7 Post by papiersam » Thu Aug 18, 2016 9:27 am

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.
I have a roundabout way to do that, then:

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"
It just needs to be tweaked so it says what you want at the speed you want. Just make sure for at least that part of the script, you disable the auto forward toggling button on the quick menu/key in the keymap.
In the end, what I was trying to do is to have text appearing slowly letter by letter in NVL mode.
I think this accomplishes that fairly.

In any case, I hope this helps.

User avatar
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.

#8 Post by dragondatingsim » Fri Aug 19, 2016 6:24 am

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!

User avatar
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.

#9 Post by papiersam » Fri Aug 19, 2016 9:14 am

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.
Weird. I tested it again with over 500 characters:

Code: Select all

    $i = 500
    
    window show
    nnvl "h"
    while i > 0:
        extend "c"
        if i%5:
            extend " " #needs spaces
        $i-=1
And it works just fine. There's probably something interfering with it on your end, I think.

User avatar
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.

#10 Post by dragondatingsim » Fri Aug 19, 2016 10:24 am

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 :/

User avatar
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.

#11 Post by papiersam » Fri Aug 19, 2016 11:13 am

My best guess is that it might be related to lower-end computers
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.

Maybe it's just your current configuration of Renpy? Other than that, I don't know what the problem is.

User avatar
gas
Miko-Class Veteran
Posts: 838
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Script to prevent input to instantly make text appear.

#12 Post by gas » Fri Aug 19, 2016 6:47 pm

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

User avatar
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.

#13 Post by papiersam » Fri Aug 19, 2016 7:11 pm

A video.
As an alternative? I suppose it would work. But in that case, ATL is better-more configurable and all.

User avatar
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.

#14 Post by dragondatingsim » Sat Aug 20, 2016 12:12 pm

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.

User avatar
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.

#15 Post by papiersam » Tue Aug 23, 2016 11:25 am

After a bit of thought, I figured, "Why not use screen timers and for loops?". This is the result:

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"        
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.

Post Reply

Who is online

Users browsing this forum: CharlieFuu69, Google [Bot], Ocelot