Pause issues

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
bobbk
Regular
Posts: 46
Joined: Tue Feb 09, 2010 8:36 am
Contact:

Pause issues

#1 Post by bobbk »

I'm having trouble using the pause function, when I use one of the pause/delay functions it erases previously drawn text.

What's wrong, is after the pause, all text from the first score is being erased.

Code: Select all

label resolutionmenu:
    
    scene bg slums
    
    show resolution at Position(ypos = 0.9)
    
    $ ui.text("First score", xpos=0.5, ypos=0.9)
    pause(1)
    $ ui.text("Second score", xpos=0.5, ypos=0.8)
I tried importing a python sleep module, but the imported function makes the entire label sleep before anything is ever displayed, here's that module below.

Code: Select all

import time
import renpy.store as store
import renpy.exports as renpy

def procedure():
    time.sleep(2.5)

# measure process time
t0 = time.clock()
procedure()
print time.clock() - t0, "seconds process time"

# measure wall time
t0 = time.time()
procedure()
print time.time() - t0, "seconds wall time"

chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Re: Pause issues

#2 Post by chronoluminaire »

That's precisely what you'd expect. The call to pause() makes Ren'Py think the two comments are separate lines, and so it erases the screen between them.
(Well, actually, it's a bit more complicated than that, since you're using ui.text() rather than just say statements. But it's the same basic principle - stuff produced by calls to ui.* functions are also blanked every statement.)

There are a couple of ways to do what you want. One is to just use normal say statements but use the "extend" speaker, which adds the new comment on to the end of what's been said so far:

Code: Select all

"First score:"
pause(1)
extend "Second score:"
If you wanted to include some numbers as well as the text, you could do that with interpolation, using %(variablename):

Code: Select all

"First score: %(s1)d" % This inserts the value of the numeric variable s1
pause(1)
extend "Second score: %(s2)d"
Another way to do what you want is to use "show text", which puts a string of text on screen and treats it like an image:

Code: Select all

show text "First score:" at Position(ypos=0.9)
pause(1)
show text "First score:\nSecond score:" at Position(ypos=0.9)
This is mentioned in the documentationfor the show statement.
If you want to have multiple text images on screen at once, you can use the ParameterizedText function:

Code: Select all

init:
    image text08 = renpy.ParameterizedText(ypos=0.8)
    image text09 = renpy.ParameterizedText(ypos=0.9)

label start:
show text08 "First score:"
pause(1)
show text09 "Second score:"
A third way to do it is using overlays: see Overlays for details.
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

bobbk
Regular
Posts: 46
Joined: Tue Feb 09, 2010 8:36 am
Contact:

Re: Pause issues

#3 Post by bobbk »

Parameterized Text is working best for me

unfortunately now I'm having trouble getting values to show up in a text string

Code: Select all

show text08 "First score: %(playerscore)d"
This isn't displaying the value correctly instead i see the code when I run it.

This is technically a show statement isn't it, why isn't interpolation http://www.renpy.org/wiki/renpy/doc/reference/Textworking with this?

User avatar
Alex
Lemma-Class Veteran
Posts: 3098
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Pause issues

#4 Post by Alex »


bobbk
Regular
Posts: 46
Joined: Tue Feb 09, 2010 8:36 am
Contact:

Re: Pause issues

#5 Post by bobbk »

I haven't bothered much with the ATL, I'm at a point where I'm going to get this to work, even if the code is messier than it has to be.

I have it working with an overlay like Chrono suggested, although since I have about 6 different scores to display I'm creating an overlay function for every one... It seems slightly code heavy for what it does, but not too much.

chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Re: Pause issues

#6 Post by chronoluminaire »

bobbk wrote:Parameterized Text is working best for me

unfortunately now I'm having trouble getting values to show up in a text string

Code: Select all

show text08 "First score: %(playerscore)d"
This isn't displaying the value correctly instead i see the code when I run it.

This is technically a show statement isn't it, why isn't interpolation http://www.renpy.org/wiki/renpy/doc/reference/Textworking with this?
Good question. I don't know why Ren'Py-style interpolation wouldn't work.

However, you could phrase it as a Python statement and use Python-style interpolation:

Code: Select all

$ renpy.show("text08", "First score: %d" % playerscore)
Note that in Ren'Py code, you interpolate with "%(playerscore)d", while in Python code, you interpolate with "%d" % playerscore.
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot]