Page 1 of 1

How can you define image with python? [SOLVED]

Posted: Wed Jul 26, 2017 7:26 am
by Luxliev
How can you define image like this:

Code: Select all

image = "image.png"
In python code? When I use renpy.image it asks me for 2 arguments instead of one.

Re: How can you define image with python?

Posted: Wed Jul 26, 2017 8:33 am
by Scribbles

Code: Select all

image imagename = "image.png"
example:

Code: Select all

image girl = "girl.png"
https://renpy.org/doc/html/quickstart.html

^ that can help with a lot of the basics, all of the documentation is there. Hope that helps! :)

Re: How can you define image with python?

Posted: Wed Jul 26, 2017 8:53 am
by Luxliev
It's not what I'm asking for. I'm asking for a way to define image in python itself not in renpy.

Like in renpy:

Code: Select all

$ a = 10
equals

Code: Select all

a = 10
in python

I want to know how do you correctly define renpy image in python because I want to create dynamic database.

Re: How can you define image with python?

Posted: Wed Jul 26, 2017 10:30 am
by Scribbles
ah ok, can't help you with that I'm afraid, but hopefully someone else can!

Re: How can you define image with python?

Posted: Wed Jul 26, 2017 1:10 pm
by shin.e.d
renpy.image needs a name to use in the script along with the displayable.

Code: Select all

init python hide:
    renpy.image("image1", Image("test/image1.png"))
    renpy.image("image_props", Image("test/image_props.png", xalign=0.5, yalign=0.2))

Using it in the script looks like this below.
Also theres 'show expression' -documentation here-
Works with Creator-Defined Displayables too. (edit: added stuff.)

Code: Select all

## these variables in python will be used in the 'show expression' later.
init python:
    image_ex = "test/image_ex.png"
    ex_solid = Solid("#fff", xysize=(300,300))

label test_images:
    show image1 at truecenter
    show image_props
    "yay images"

    ## expression
    show expression image_ex at topright
    "another image!"
    
    ## expression 2
    show expression ex_solid as ex_solid ## 'as' gives it a name.
    "a solid white square."

    hide ex_solid
    "it disappeared."
edit2 Oops abit too tired today to be posting... you'd probably want it in screens, right? Here it is in screen language xD:

Code: Select all

## use init -2 to ensure it's defined before the screens.
init -2 python:
    new_image = Image("test/image.png")

screen test_add:
    add new_image:
        xalign 0.8