Ren'Py questions

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
Icekiss
Regular
Posts: 100
Joined: Sun Oct 10, 2004 4:04 pm
Contact:

Ren'Py questions

#1 Post by Icekiss »

Alright, I really couldn't place this in "working on DSE", since it doesn't have the first thing to do with it. So I thought I'd at least keep the thread general, so that other people can use it to ask questions in it to, instead of opening up a new thread each time...

Question:
I have been doing a small side project in the last few hours.
All I am doing, is grabbing a picture from a folder, waiting for the user (via ui.saybehavior+ui.interact ), looping and displaying the next one.

Works wonderfully. Problem: Interactive rollback doesn't work. While saving and loading does. I already tried to add renpy.checkpoint(). I don't know what I am overlooking.
If you are a debian linux user, take a look at my program: http://deb-install.sourceforge.net/

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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:

#2 Post by PyTom »

My gut feeling is you're looping inside a python block. Rollback has a granularity of one Ren'Py statement... so if you never leave the block, you'll never be able to rollback to it.

Use a Ren'Py while statement rather than a Python for or while statement as your loop, and it _should_ work.

Icekiss
Regular
Posts: 100
Joined: Sun Oct 10, 2004 4:04 pm
Contact:

#3 Post by Icekiss »

Nope, I am leaving the python block.
However, I am not using the while statement either. I am just jumping back to the loop label (same way the DSE main loop works, basically).
config.rollback_enabled = True
config.hard_rollback_limit = config.rollback_length
If you are a debian linux user, take a look at my program: http://deb-install.sourceforge.net/

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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:

#4 Post by PyTom »

Hm... I'd have to look at the code to see what's going on, then.

Icekiss
Regular
Posts: 100
Joined: Sun Oct 10, 2004 4:04 pm
Contact:

#5 Post by Icekiss »

It's not long, so I am just going to paste it in here.

Code: Select all

label start:

label main_loop:    
    scene black
    
    python:
        renpy.checkpoint()
        
        #does the image exist?
        numberstring=str(stripnumber)
        if stripnumber< 10: numberstring='0'+numberstring
        if stripnumber<100: numberstring='0'+numberstring
        filename=numberstring+letters[letterN]
        file=find_file(filename, imageFolders, imageEndings)
        
    if not file:
        jump main_end
        
    python:
        #display a heading, and the picture
        ui_image( None, 'Strip '+str(stripnumber), textSize=30, fillColor=(0,0,0,0),
            xpos=0.5, xanchor='center', ysize=100 )
        ui_image( file, None, scaleImage=2.0,
            xpos=0.5, xanchor='center', ysize=400 )
        
        ui.saybehavior()
        
        #transition if the stripnumber changed
        if letterN==0:
            renpy.transition( dissolve )
    
        #paint on screen, and wait for user to proceed
        ui.interact()
    
        #change stripnumber and letterN to point to the next image
        if letterN==len(letters)-1:
            letterN=0
            stripnumber+=1
        else: letterN+=1
    
    #and loop...
    jump main_loop
If you need to look at ui_image and/or find_file as well, just tell me.
If it would me more convenient to have the script send as e-mail: again, just tell me. :-)
If you are a debian linux user, take a look at my program: http://deb-install.sourceforge.net/

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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:

#6 Post by PyTom »

Try putting the renpy.checkpoint() right after the ui.interact().

My gut instinct is that what's going on is we're rolling back from the second python block to the first, then immediately rolling forward to the second, giving the appearance of there being no rollback.

(So a print statement put before the ui.interact() would print something out every time you try to roll back.)

Special bonus hint:

Code: Select all

        numberstring=str(stripnumber)
        if stripnumber< 10: numberstring='0'+numberstring
        if stripnumber<100: numberstring='0'+numberstring
Can be written as:

Code: Select all

       numberstring = "%03d" % stripnumber

Icekiss
Regular
Posts: 100
Joined: Sun Oct 10, 2004 4:04 pm
Contact:

#7 Post by Icekiss »

Thanks! Works, and works. :D
If you are a debian linux user, take a look at my program: http://deb-install.sourceforge.net/

Icekiss
Regular
Posts: 100
Joined: Sun Oct 10, 2004 4:04 pm
Contact:

#8 Post by Icekiss »

Just got the following error
Exception: Surface alphas do not match.
I tried to make a gif image half transparent ( via im.Alpha( image, alpha ) ).
Is Ren'Py trying to tell me it can't do it because gifs don't have an alpha channel?
If so, it's pretty poorly worded. Or is something else going on?

EDIT after answer (saw it too late): And while I am asking: Any way to get the point across to Ren'Py that an interaction hasn't occured yet? Right now Ren'Py allows me to skip unseen pictures as well. Would generating from clauses on the fly help? (Haven't looked whether that is possible yet)
Last edited by Icekiss on Thu Aug 11, 2005 7:44 am, edited 2 times in total.
If you are a debian linux user, take a look at my program: http://deb-install.sourceforge.net/

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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:

#9 Post by PyTom »

Hm... What Ren'Py version are you using, and what bit-depth are you running at, and is there an alpha channel already in your image? (The latter may be hard to tell.)

The error you're getting can never happen... Which means I need to find out why it's happening.

A drop of the code would be nice, but I won't be able to deal with it until tonight.

Icekiss
Regular
Posts: 100
Joined: Sun Oct 10, 2004 4:04 pm
Contact:

#10 Post by Icekiss »

In this case stock Ren'Py 5.0.1

Depth should be 16bpp (thats the first number in the list for screen0, and I can see the staircase effect on my screen)

Can't figure how to tell whether the gif has an alpha channel. Konqueror doesn't provide meta data on it, and I can't find where gimp gives out general informations about the picture I am viewing. Name of an utility I can use to tell would be appreciated.

actual code:

Code: Select all

    $ strip_alpha=0.9

Code: Select all

        ui_image( file, None, scaleImage=2.0, alpha=strip_alpha,
            xpos=strip_xpos, xanchor=strip_xanchor, ysize=strip_ysize )

Code: Select all

                image=im.Image( filename )
                if scaleImage==True: image=im.Scale( image, xsize, ysize )
                if str(scaleImage)[0].isdigit(): image=im.Rotozoom( image, 0, scaleImage )
                if alpha!=1.0: image=im.Alpha( image, alpha )
or, condensed to what should be important here:

Code: Select all

                image=im.Image( filename )
                image=im.Rotozoom( image, 0, 2.0 )
                image=im.Alpha( image, 0.9 )
If you are a debian linux user, take a look at my program: http://deb-install.sourceforge.net/

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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:

#11 Post by PyTom »

Icekiss wrote:In this case stock Ren'Py 5.0.1

Depth should be 16bpp (thats the first number in the list for screen0, and I can see the staircase effect on my screen)
I'd try it at 24, to see if that matters. Ren'Py 5.0.1 should always run at 24 or 32 bits internally... but obviously something is going wrong.
Can't figure how to tell whether the gif has an alpha channel. Konqueror doesn't provide meta data on it, and I can't find where gimp gives out general informations about the picture I am viewing. Name of an utility I can use to tell would be appreciated.
Go into GIMP, and try erasing the image. If it erases to white, no alpha channel, to the gray checkerboard, alpha channel.

Code: Select all

                image=im.Image( filename )
                image=im.Rotozoom( image, 0, 2.0 )
                image=im.Alpha( image, 0.9 )
What happens if you disable the rotozoom? Also, is this happening with every image, or one particular image.

When I get home tonight, I'll try setting up a 16bpp X server so I can properly troubleshoot this.

Icekiss
Regular
Posts: 100
Joined: Sun Oct 10, 2004 4:04 pm
Contact:

#12 Post by Icekiss »

Taking the rotozoom out prevents the error from occuring!

I haven't found an image in this series where it doesn't happen.

Gimp shows white background -> no alpha channel in the gifs.

Setting up my own xserver to do 24bpp would be more work (Must have run into some stumbling block when I set up linux, or else it would be in use right now). Might try it later.
If you are a debian linux user, take a look at my program: http://deb-install.sourceforge.net/

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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:

#13 Post by PyTom »

Okay, I think I can take it from here, when I get home.

Icekiss
Regular
Posts: 100
Joined: Sun Oct 10, 2004 4:04 pm
Contact:

#14 Post by Icekiss »

Glad I could be of help. :D

Two other questions (no bugs, just questions :wink: ):

1)
Any way to get the point across to Ren'Py that an interaction hasn't occured yet? Right now Ren'Py allows me to skip unseen pictures as well. Would generating from clauses on the fly help? (Haven't looked whether that is possible yet)

2)
While I can add images created via im functions as widgets (via ui.add( image ); ha, found that one myself :D ), ui.add doesn't take positional parameters.
So I have to wrap it into another widget that does. I am currently using ui.fixed for this. But since ui.fixed doesn't react to xfill/yfill, that doesn't work too well when I don't know the size of the image (when I do, I can use xmaximum and ymaximum to restrict ui.fixed to the size of the image).
So what's the easiest way of doing the wrapping? Taking ui.window and stylizing all padding and background away?
Or determinig the size of the image? (How?)
(Basically a question I can figure out myself via brute force. But you could probably point in me in the right direction with a single sentence. So I am asking.)
If you are a debian linux user, take a look at my program: http://deb-install.sourceforge.net/

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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:

#15 Post by PyTom »

Icekiss wrote: 1) Any way to get the point across to Ren'Py that an interaction hasn't occured yet? Right now Ren'Py allows me to skip unseen pictures as well. Would generating from clauses on the fly help? (Haven't looked whether that is possible yet)
No, not really. The granularity of the skipping is on the Ren'Py statement level... once you've interacted inside a Ren'Py statement, that statement is eligible to be skipped. I can't think of any other rule for this that makes sense, at least for the type of games Ren'Py is aimed at.

You seem to be making some sort of image viewer... This is, to some extent, beyond what Ren'Py is really good at.
While I can add images created via im functions as widgets (via ui.add( image ); ha, found that one myself :D ), ui.add doesn't take positional parameters.
I believe that ui.image should be able to take an im-constructed image as its first argument, and it also takes properties as arguments.

Post Reply

Who is online

Users browsing this forum: Ocelot, trailsiderice