Problem with random dynamic side images

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
tremmiGames
Newbie
Posts: 2
Joined: Sun May 29, 2022 3:49 am
itch: tremmigames
Contact:

Problem with random dynamic side images

#1 Post by tremmiGames »

Hello devs and community! This is my first post on this forum so please be patient with my stupid question :)

I work on new VN and now I have a problem.
I have an idea to create random dynamic side images.
Here is an example of correct working code:

Code: Select all

image angel_side_smile:
   "angel_side_0" with Dissolve(0.2, alpha=True)
    pause 0.2
    "angel_side_1" with Dissolve(0.2, alpha=True)
    pause 0.2
    "angel_side_2" with Dissolve(0.2, alpha=True)
    pause 0.2
    "angel_side_1" with Dissolve(0.2, alpha=True)
    pause 0.2
    "angel_side_0" with Dissolve(0.2, alpha=True)
    pause 0.8
    "angel_side_3" with Dissolve(0.2, alpha=True)
    pause 0.2
    "angel_side_4" with Dissolve(0.2, alpha=True)
    pause 0.2
    "angel_side_5" with Dissolve(0.2, alpha=True)
    pause 0.2
    "angel_side_4" with Dissolve(0.2, alpha=True)
    pause 0.2
    "angel_side_3" with Dissolve(0.2, alpha=True)
    pause 0.2
    "angel_side_0" with Dissolve(0.2, alpha=True)
    pause 5
    repeat

This is what I want to do.:

Code: Select all

image angel_side_smile:
    $ show_angel_smile = renpy.random.choice(["1", "2", "3", "4"])
    if show_angel_smile == "1" or show_angel_smile == "2" or show_angel_smile == "3":
        "angel_side_0" with Dissolve(0.2, alpha=True)
        pause 0.2
        "angel_side_1" with Dissolve(0.2, alpha=True)
        pause 0.2
        "angel_side_2" with Dissolve(0.2, alpha=True)
        pause 0.2
        "angel_side_1" with Dissolve(0.2, alpha=True)
        pause 0.2
        "angel_side_0" with Dissolve(0.2, alpha=True)
        pause 5
    elif show_angel_smile == "4":
        "angel_side_0" with Dissolve(0.2, alpha=True)
        pause 0.2
        "angel_side_3" with Dissolve(0.2, alpha=True)
        pause 0.2
        "angel_side_4" with Dissolve(0.2, alpha=True)
        pause 0.2
        "angel_side_5" with Dissolve(0.2, alpha=True)
        pause 0.2
        "angel_side_4" with Dissolve(0.2, alpha=True)
        pause 0.2
        "angel_side_3" with Dissolve(0.2, alpha=True)
        pause 0.2
        "angel_side_0" with Dissolve(0.2, alpha=True)
        pause 5
    repeat
Then I got this error.

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/dynamic.rpy", line 53: expected 'comma or end of line' not found.
    $ show_angel_smile = renpy.random.choice(["1", "2", "3", "4"])
    ^

Ren'Py Version: Ren'Py 7.4.11.2266
Sun May 29 11:37:10 2022
I understand that in image there is no way to insert the variables, but I still think that there is a correct way to do it.
I tried to insert random before the image, but this works only once and remember the result and use it every time.
Could someone help me with my problem ? :)

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2403
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Problem with random dynamic side images

#2 Post by Ocelot »

https://www.renpy.org/doc/html/atl.html ... -statement

Just make those two alternatives into choices instead.
< < insert Rick Cook quote here > >

tremmiGames
Newbie
Posts: 2
Joined: Sun May 29, 2022 3:49 am
itch: tremmigames
Contact:

Re: Problem with random dynamic side images

#3 Post by tremmiGames »

Ocelot wrote: Sun May 29, 2022 5:21 am https://www.renpy.org/doc/html/atl.html ... -statement

Just make those two alternatives into choices instead.
It works :) Thank you very much :) I am happy with that :)

Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot], Ocelot