Page 1 of 1

ATL like choices in labels

Posted: Fri Feb 03, 2023 1:54 pm
by mold.FF
Hi guys,

Is it possible to implement a "choice" feature from the ATL into regular labels?
I like how I can do this:

Code: Select all

image lucy:
    "lucy_calm"
    4.
    choice:
        "lucy_wierd_1"
    choice:
        "lucy_wierd_2"
    choice:
        "lucy_wierd_3"
    1.
    repeat
And Lucy will stay calm for 4 seconds then do a wierdo with 3 random variations for 1 second, and return to calm for another 4 seconds.
It would be awesome if I could do something similar in dialogs:

Code: Select all

label classroom:
    "I've entered a classroom."
    choice:
        friend1 "Whatsup?"
    choice:
        friend2 "Yo!"
    choice:
        classmates "(Noise)"
    call screen WhatToDoInClassroom()
I know I can use renpy.random for that purpose, and thats what I'm using right now:

Code: Select all

label classroom:
    "I've entered a classroom."
    $ my_random = renpy.random.randint(1, 3)
    if my_random == 1:
        friend1 "Whatsup?"
    elif my_random == 2:
        friend2 "Yo!"
    elif my_random == 3:
        classmates "(Noise)"
    call screen WhatToDoInClassroom()
But there is a couple downsides in this method in comparison to "choices" in ATL:
- things it's starting getting harder when I need to use random within another random
- I have to specify amount of variations beforehand
- weighted random are harder to do

Re: ATL like choices in labels

Posted: Sat Feb 04, 2023 2:06 am
by _ticlock_
mold.FF wrote: Fri Feb 03, 2023 1:54 pm Is it possible to implement a "choice" feature from the ATL into regular labels?
You can create custom RenPy statement using Creator-Defined Statements
Check the example in the documentation, it is pretty close to what you are looking for.

Re: ATL like choices in labels

Posted: Sat Feb 04, 2023 6:14 pm
by mold.FF
_ticlock_ wrote: Sat Feb 04, 2023 2:06 am
mold.FF wrote: Fri Feb 03, 2023 1:54 pm Is it possible to implement a "choice" feature from the ATL into regular labels?
You can create custom RenPy statement using Creator-Defined Statements
Check the example in the documentation, it is pretty close to what you are looking for.
!!!
I see how useful this feature could be.
A Big Thank You, _ticlock_

As far as I understood it, it allow me to do the following:
1. Make a "random" statement, which will run a random choice from the global random_choices list on post_execute phase.
2. Make a "choice" statement, which will add a given script block to the global random_choices list, or something like that.

Code: Select all

label classroom:
    "I've entered a classroom."
    random:
        choice:
            friend1 "Whatsup?"
            $ available_options.append("friend1") ## new addition, to show that I need a script section here, not just a random line.
        choice:
            friend2 "Yo!"
            $ available_options.append("friend2") ## new addition, to show that I need a script section here, not just a random line.
        choice:
            classmates "(Noise)"
    call screen WhatToDoInClassroom()
A pure choice - like in example I've posted earlier - looks like a far goal for me now.