Page 1 of 1

Problem with Flip Image

Posted: Sat Nov 18, 2017 5:18 am
by Bryy
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.

Re: Problem with Flip Image and Conditionals

Posted: Sat Nov 18, 2017 9:08 am
by Remix
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

Re: Problem with Flip Image and Conditionals

Posted: Sat Nov 18, 2017 11:15 pm
by Bryy
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.

Re: Problem with Flip Image and Conditionals

Posted: Mon Nov 20, 2017 10:04 am
by Remix
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

Re: Problem with Flip Image and Conditionals

Posted: Tue Nov 21, 2017 7:28 pm
by Bryy
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.

Re: Problem with Flip Image and Conditionals

Posted: Tue Nov 21, 2017 7:54 pm
by Remix
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.

Re: Problem with Flip Image

Posted: Wed Nov 22, 2017 3:49 am
by vollschauer
As Remix said, don't use im.Flip! It is better to go with ATL xzoom/yzoom instead....

Re: Problem with Flip Image

Posted: Thu Dec 07, 2017 9:38 am
by Errilhl
"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"

Re: Problem with Flip Image

Posted: Thu Dec 07, 2017 10:00 am
by philat
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.