[Solved]Add text in image in list

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
bonnie_641
Regular
Posts: 133
Joined: Sat Jan 13, 2018 10:57 pm
Projects: Código C.O.C.I.N.A.
Deviantart: rubymoonlily
Contact:

[Solved]Add text in image in list

#1 Post by bonnie_641 »

Code: Select all

label renpy_:#(1,2)fc
    #scene receta_generico
    $ ren0 = ['{b}{size=+3}{u}Prueba Título {/u}{/size}{/b}',
        '{size=-2}\nTEXTTTTTT XD{/size}' 
        'More text',
        '\n{image=deco}\n', # <--- I add the image but it does not allow me to add text over it 
        '{u}subtitle nº 1{/u}: {a=lenguaje}see link content{/a}',
        ]

    call screen renpai

screen renpai():
    add "images/ren.png" pos (0,119)
    text "{b}{size=+5}Link content {/size}{/b}" pos (78,67)

    imagebutton:#
        idle "images/cerrar.png"
        hover "images/cerrar_h.png"
        pos (1051,60)
        focus_mask True
        #activate_sound 'click.wav'
        action Jump("renpy_")

    frame:#documentación renpy
        background None
        area (320, 147, 870, 550) #(x, y, w, h)
        viewport:
            id "ren_0"
            draggable True
            scrollbars "vertical"
            mousewheel True
            has vbox
            for i in ren0:
                text i

Code: Select all

$ ren0 
[...]
for i in ren0:
    text i
the 'for' goes through all the content of $ren0. However what I want to do is to add a text over the image in the $ren0 block.I want to reuse the image several times. Is it possible?

Thank you in advance
Last edited by bonnie_641 on Tue Aug 03, 2021 1:46 pm, edited 1 time in total.
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question. :wink:

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: [Help]Add text in image in list

#2 Post by hell_oh_world »

Probably just make the list a list of displayables and use add instead.

Code: Select all

define disps = (
  Text("txt1"),
  Text("txt2"),
  Fixed("image name", Text("txt3"))
)

screen test():
  for d in disps:
    add d

User avatar
bonnie_641
Regular
Posts: 133
Joined: Sat Jan 13, 2018 10:57 pm
Projects: Código C.O.C.I.N.A.
Deviantart: rubymoonlily
Contact:

Re: [Help]Add text in image in list

#3 Post by bonnie_641 »

hell_oh_world wrote: Tue Aug 03, 2021 8:27 am Probably just make the list a list of displayables and use add instead.

Code: Select all

define disps = (
  Text("txt1"),
  Text("txt2"),
  Fixed("image name", Text("txt3"))
)

screen test():
  for d in disps:
    add d
It worked! :D
Thank you very much <3
I leave backup in case I forget this process XD (or for someone who needs it).

Code: Select all

# Added the missing variable to make the request work (: (by hell_oh_world)
define disps = (
    Text(""),
    Fixed("deco", Text("\n    Test text over image")) #<--- text over image (called deco) with line breaks and white spaces.
)

label renpy_:
    #scene receta_generico
    $ ren0 = ['{b}{size=+3}{u}Test Title {/u}{/size}{/b}',
        '{size=-2}\nTEXTTTTTT XD{/size}' 
        'More text',
        #'\n{image=deco}\n', 
        '{u}subtitle nº 1{/u}: {a=lenguaje}see link content{/a}',
        ]

    call screen renpai

screen renpai():
    add "images/ren.png" pos (0,119)
    text "{b}{size=+5}Link content {/size}{/b}" pos (78,67)

    imagebutton:
        idle "images/cerrar.png"
        hover "images/cerrar_h.png"
        pos (1051,60)
        focus_mask True
        #activate_sound 'click.wav'
        action Jump("renpy_")

    frame:
        background None
        area (320, 147, 870, 550) #(x, y, w, h)
        viewport:
            id "ren_0"
            draggable True
            scrollbars "vertical"
            mousewheel True
            has vbox
            for i in ren0:
                text i
            frame:
                background None
                for d in disps: #<------------- what you had on the screen of the previous post (thanks hell_oh_world)
                    add d         # <3
PD: This code is linked to a local search engine. I only put in the part of the code that didn't work at all.
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question. :wink:

Post Reply

Who is online

Users browsing this forum: Google [Bot]