Problem with Flip Image

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
User avatar
Bryy
Veteran
Posts: 236
Joined: Thu Dec 20, 2012 10:12 pm
Completed: Army of Tentacles 1 & 2, The Ghost of Joe Papp
Projects: Paper Shakespeare: To Date or Not To Date?
Organization: Stegalosaurus Game Development
Location: Bay Area, CA
Contact:

Problem with Flip Image

#1 Post by Bryy » Sat Nov 18, 2017 5:18 am

So, my last game had a boatload of character images for their left and right image positions. This was for the characters with outfit conditionals. The regular character images, I could use Image Flip fine.

So my code for my Party Members looks like this:

Code: Select all

        #APOCALYPSE BUNNY
default bunny_outfit = "c1"
define ab = Character('Apocalypse Bunny', color="#FF3D3D",show_two_window=True)
image bunny shock = "2_4_[bunny_outfit]_2.png"
image bunny shock LFT = "2_4_[bunny_outfit]_1.png"
image bunny angry = "2_2_[bunny_outfit]_2.png"
image bunny angry LFT = "2_2_[bunny_outfit]_1.png"
image bunny hurt = "2_3_[bunny_outfit]_2.png"
image bunny hurt LFT = "2_3_[bunny_outfit]_1.png"
image bunny happy = "2_1_[bunny_outfit]_2.png"
image bunny happy LFT = "2_1_[bunny_outfit]_1.png"
image bunny sad = "2_2a_[bunny_outfit]_2.png"
image bunny sad LFT = "2_2a_[bunny_outfit]_1.png"
While my code to change the image to work in battles looks like this:

Code: Select all

        "{color=#FFFF00}Outfit: {color=#08E836}New Clothes":
            if persistent.ng is False:
                call cthulhu
                $globalClock.AddTime(0, 1, 5)
                jump closet
            else:
                if change_perry:
                    if boy:
                        $perry.image = "1_5_male_" + perry_outfit
                    else:
                        $perry.image = "1_5_fem_" + perry_outfit
                    $perry.image_path = "images/" + perry.image + ".png"
I have no issues with the images in battles, I'm just showing that code because it may be related to my real problem/question.

When I write:

Code: Select all

 image bunny hurt LFT = im.Flip("2_3_[bunny_outfit]_1.png", horizontal=True)
It comes back with the error:

Code: Select all

IOError: Couldn't find file '2_3_[bunny_outfit]_1.png'.
My goal is to somehow find code that allows for Image Flip with Conditionals so that I don't need to stuff my images folder with so many redundant images.
Last edited by Bryy on Tue Nov 21, 2017 7:51 pm, edited 1 time in total.

User avatar
Remix
Veteran
Posts: 361
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet
Projects: An un-named 3d anime based trainer game
Contact:

Re: Problem with Flip Image and Conditionals

#2 Post by Remix » Sat Nov 18, 2017 9:08 am

It would seem that the string is not being interpolated. I am not sure if there is a parameter to pass to im.Flip which would get passed to the child. You could try a few guesses...

image bunny hurt LFT = im.Flip("2_3_[bunny_outfit]_1.png", horizontal=True, dynamic=True)
image bunny hurt LFT = im.Flip("2_3_[bunny_outfit]_1.png", horizontal=True, substitute=True)
... one might work...

else maybe
image bunny hurt LFT = im.Flip( DynamicImage("2_3_[bunny_outfit]_1.png"), horizontal=True)
or
image bunny hurt LFT = im.Flip( renpy.displayable("2_3_[bunny_outfit]_1.png"), horizontal=True)
or
image bunny hurt LFT = im.Flip( renpy.substitute("2_3_[bunny_outfit]_1.png"), horizontal=True)
might well force the interpolation

User avatar
Bryy
Veteran
Posts: 236
Joined: Thu Dec 20, 2012 10:12 pm
Completed: Army of Tentacles 1 & 2, The Ghost of Joe Papp
Projects: Paper Shakespeare: To Date or Not To Date?
Organization: Stegalosaurus Game Development
Location: Bay Area, CA
Contact:

Re: Problem with Flip Image and Conditionals

#3 Post by Bryy » Sat Nov 18, 2017 11:15 pm

Now I get this (when running the displayable code):

Code: Select all

While running game code:
  File "game/script.rpy", line 3981, in script
    image bunny hurt LFT = im.Flip( renpy.displayable("2_3_[bunny_outfit]_1.png"), horizontal=True) #image bunny hurt LFT = "2_3_[bunny_outfit]_1.png"
  File "game/script.rpy", line 3981, in <module>
    image bunny hurt LFT = im.Flip( renpy.displayable("2_3_[bunny_outfit]_1.png"), horizontal=True) #image bunny hurt LFT = "2_3_[bunny_outfit]_1.png"
Exception: Expected an image, but got a general displayable.

User avatar
Remix
Veteran
Posts: 361
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet
Projects: An un-named 3d anime based trainer game
Contact:

Re: Problem with Flip Image and Conditionals

#4 Post by Remix » Mon Nov 20, 2017 10:04 am

maybe just flip it with ATL when needed...

Code: Select all

image bunny hurt = DynamicImage( "2_3_[bunny_outfit]_1.png" )

...
show bunny hurt:
    xzoom -1.0

User avatar
Bryy
Veteran
Posts: 236
Joined: Thu Dec 20, 2012 10:12 pm
Completed: Army of Tentacles 1 & 2, The Ghost of Joe Papp
Projects: Paper Shakespeare: To Date or Not To Date?
Organization: Stegalosaurus Game Development
Location: Bay Area, CA
Contact:

Re: Problem with Flip Image and Conditionals

#5 Post by Bryy » Tue Nov 21, 2017 7:28 pm

I might try that for the next game (and of course I'll test it first); looks like for the current game, I'm stuck with the code I have just cause there's so much flipping going on.

But as for outfit changes, still getting the same errors whenever I add in the _[]s.

User avatar
Remix
Veteran
Posts: 361
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet
Projects: An un-named 3d anime based trainer game
Contact:

Re: Problem with Flip Image and Conditionals

#6 Post by Remix » Tue Nov 21, 2017 7:54 pm

Did none of the options work? The renpy.substitute one should pre-interpolate the string, which seems fine (presuming im.Flip() normally support just an image path and name) and even the DynamicImage one should do better. No time to test them here though.

User avatar
vollschauer
Veteran
Posts: 201
Joined: Sun Oct 11, 2015 9:38 am
Github: vollschauer
Contact:

Re: Problem with Flip Image

#7 Post by vollschauer » Wed Nov 22, 2017 3:49 am

As Remix said, don't use im.Flip! It is better to go with ATL xzoom/yzoom instead....

Errilhl
Regular
Posts: 150
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Contact:

Re: Problem with Flip Image

#8 Post by Errilhl » Thu Dec 07, 2017 9:38 am

"Better" as in...?

Using the ATL xzoom / yzoom seems to have to be declared for every show-statement - if you randomly set flip-state (which I do) that is a lot of

Code: Select all

if renpy.random.random() > .5:
    xzoom -1.0
(Not even sure that will work, since I haven't tested it
Is there really no way to use both im.Flip and DynamicImage in the same line? If so... why not?

This seems (to me, at least) like a basic thing that should be present when you're talking about a game that is basically "display images and text"
Currently working on: Image

philat
Eileen-Class Veteran
Posts: 1245
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Problem with Flip Image

#9 Post by philat » Thu Dec 07, 2017 10:00 am

https://www.renpy.org/doc/html/displaya ... nipulators

Image manipulators have specific conditions. They do not change with gamestate. They do not take general displayables, only images. Them's the breaks. *shrug*

ATL does not have to be declared for every show statement; it can be part of image declaration.

Post Reply

Who is online

Users browsing this forum: Remix