Page 1 of 1

Label as main menu background

Posted: Tue Mar 19, 2024 6:19 pm
by neometalero
I have this label on my script file, basically it works as a gallery of pictures with some transitions added to it. I want to put this as the main menu background. Any idea on how I could do this?

Code: Select all

label menuCarruselTest:
    $numPoster=renpy.random.randint(1,cantImgMainMenu)
    #Si es el que acaba de salir sortea denuevo
    if numPoster==numAnterior:
        jump menuCarruselTest

    $numAnterior=numPoster #guardo cual fue el que salio
    $numPosterstr="[numPoster]" #lo convierto a string
    $imagenAMostrarMM="MainMenuPresent/Poster-"+numPosterstr+".png" #arma la imagen a mostrar

    show image (imagenAMostrarMM) at MMTransicion
    $ renpy.pause(5.0, hard=True) #para hacer una pausa, y el hard es para que no se la salteen
    scene black
    with dissolve
    $contadorAlPedo=contadorAlPedo+1
    if contadorAlPedo==1000:
        return #sale del programa, es para evitar un loop infinito
    else:
        jump menuCarruselTest

Re: Label as main menu background

Posted: Wed Mar 20, 2024 4:49 am
by Ocelot
If main_menu label exist, it will be executed, instead of showing the main menu screen. Note that you will be responsible for shwing and handling all menu screens in this case.
An alternative approach is to convert you code into a screen and use that instead.

Re: Label as main menu background

Posted: Wed Mar 20, 2024 10:22 am
by neometalero
Ocelot wrote: Wed Mar 20, 2024 4:49 am If main_menu label exist, it will be executed, instead of showing the main menu screen. Note that you will be responsible for shwing and handling all menu screens in this case.
An alternative approach is to convert you code into a screen and use that instead.
How can I write this in screen language? I can't use jumps or repeat. Hoy could I accomplish the same loop?

Re: Label as main menu background

Posted: Wed Mar 20, 2024 3:52 pm
by Ocelot
a) Use timers that change varable controlling current image.
b) CDD which change rendered image based on elapsed time
c) Potentially ATL animation which has a funtcion statement changing child of transform.

Re: Label as main menu background

Posted: Wed Mar 20, 2024 5:36 pm
by neometalero
Ocelot wrote: Wed Mar 20, 2024 3:52 pm a) Use timers that change varable controlling current image.
b) CDD which change rendered image based on elapsed time
c) Potentially ATL animation which has a funtcion statement changing child of transform.
Right now Im triying to do it this way, as an animated image

Code: Select all

image MMCarrusAsImgSimple:
    ("MainMenuPresent/Poster-"+(renpy.random.randint(1,cantImgMainMenu))+".png") at MMTransicion
    pause 5
    repeat
but Im getting the following error.
Image

Re: Label as main menu background

Posted: Thu Mar 21, 2024 3:14 am
by Ocelot
You cannot simply add random code and expect it to work. ATL has different syntax from both RenPy script and SL, so you'll need more complex approach. This, for example will change bachground from red to green and back every 3 seconds:

Code: Select all

init python:
    def change_image(trans, st, at):
        if (at // 3) % 2 == 0:
            trans.set_child(Solid("#0F0"))
        else:
            trans.set_child(Solid("#F00"))
        return None


image green_to_red:
    function change_image
    pause 1.0
    repeat

label start:
    show green_to_red
    "..."
    return
[code]
If you have any transitions you want to use, you will have to bake them into [c]funtion[/c] code as well. In this case I heavily suggest go with "screen with timers" approach instead.