How can you define image with python? [SOLVED]

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
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

How can you define image with python? [SOLVED]

#1 Post by Luxliev » Wed Jul 26, 2017 7:26 am

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.
Last edited by Luxliev on Thu Aug 24, 2017 1:58 am, edited 1 time in total.
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

User avatar
Scribbles
Miko-Class Veteran
Posts: 636
Joined: Wed Sep 21, 2016 4:15 pm
Completed: Pinewood Island, As We Know It
Projects: In Blood
Organization: Jaime Scribbles Games
Deviantart: breakfastdoodles
itch: scribbles
Location: Ohio
Contact:

Re: How can you define image with python?

#2 Post by Scribbles » Wed Jul 26, 2017 8:33 am

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! :)
Image - Image -Image

User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: How can you define image with python?

#3 Post by Luxliev » Wed Jul 26, 2017 8:53 am

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.
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

User avatar
Scribbles
Miko-Class Veteran
Posts: 636
Joined: Wed Sep 21, 2016 4:15 pm
Completed: Pinewood Island, As We Know It
Projects: In Blood
Organization: Jaime Scribbles Games
Deviantart: breakfastdoodles
itch: scribbles
Location: Ohio
Contact:

Re: How can you define image with python?

#4 Post by Scribbles » Wed Jul 26, 2017 10:30 am

ah ok, can't help you with that I'm afraid, but hopefully someone else can!
Image - Image -Image

User avatar
shin.e.d
Newbie
Posts: 22
Joined: Sat Jan 10, 2015 10:50 am
Projects: Data Lion and an unnamed bxb game with dinosaurs!
Contact:

Re: How can you define image with python?

#5 Post by shin.e.d » Wed Jul 26, 2017 1:10 pm

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

Post Reply

Who is online

Users browsing this forum: Google [Bot]