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.
-
CatNip23
- Newbie
- Posts: 6
- Joined: Wed Jul 29, 2020 12:16 pm
-
Contact:
#1
Post
by CatNip23 » Mon Jun 27, 2022 12:14 pm
Hello, I would like to show some specific ATL animations but I'm having some problems.
The choice statement chooses block with equal probabilites, but I would like to have some weights when choosing, like this:
Code: Select all
image anim1:
choice if renpy.random.randint(1, 10) > 3:
"animation1.png"
0.07
"animation2.png"
0.07
"animation3.png"
0.07
choice else:
"animation4.png"
0.07
"animation5.png"
0.07
"animation6.png"
0.07
repeat
That way, the first block would happen 70% of the time, and the second 30%. How would I go about something like this?
-
Ocelot
- Eileen-Class Veteran
- Posts: 1882
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
-
Contact:
#2
Post
by Ocelot » Mon Jun 27, 2022 12:18 pm
CatNip23 wrote: ↑Mon Jun 27, 2022 12:14 pm
The choice statement chooses block with equal probabilites
The documentation disagrees:
https://www.renpy.org/doc/html/atl.html ... -statement
Code: Select all
atl_choice ::= "choice" (simple_expression)? ":"
atl_block
Choice statements are greedily grouped into a choice set when more than one choice statement appears consecutively in a block.
If the simple_expression is supplied, it is a floating-point weight given to that block, otherwise 1.0 is assumed.
< < insert Rick Cook quote here > >
-
CatNip23
- Newbie
- Posts: 6
- Joined: Wed Jul 29, 2020 12:16 pm
-
Contact:
#3
Post
by CatNip23 » Mon Jun 27, 2022 12:36 pm
It's not clear to me how I would use it. I tried using:
Code: Select all
image anim1:
atl_choice ::= "choice" (0.7)? ":"
"animation1.png"
0.07
"animation2.png"
0.07
"animation3.png"
0.07
atl_choice ::= "choice" (0.3)? ":"
"animation4.png"
0.07
"animation5.png"
0.07
"animation6.png"
0.07
repeat
But it didn't work
-
Ocelot
- Eileen-Class Veteran
- Posts: 1882
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
-
Contact:
#4
Post
by Ocelot » Mon Jun 27, 2022 1:00 pm
It is a Backus–Naur form of defining syntax. It says, that atl_choice statement consist of
* literal word "choice" (without quotes)
* optional
simple_expression (which can be a number, variable, etc...)
* literal ":" (semicolon without quotes)
* indented atl_block
So you can write it like:
Notice how the only difference between usual choice statement and this is a single expression between "choice" and ":"
< < insert Rick Cook quote here > >
-
CatNip23
- Newbie
- Posts: 6
- Joined: Wed Jul 29, 2020 12:16 pm
-
Contact:
#5
Post
by CatNip23 » Mon Jun 27, 2022 1:08 pm
Oh, it's a lot simpler than I thought. Thanks!
Users browsing this forum: Google [Bot]