Changing the yanchor (in screens.rpy) using if statement

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
Kaia
Newbie
Posts: 1
Joined: Thu Dec 06, 2018 4:40 pm
itch: https://itch.io/prof
Contact:

Changing the yanchor (in screens.rpy) using if statement

#1 Post by Kaia »

My pseudo code looks something like this

if the number of dialogue choices is 2, make the value of yanchor -1.5
if the number of dialogue choices is 3, make the value of yanchor -0.6
if the number of dialogue choices is >4, make the value of yanchor -0.4

And my screens.rpy currently looks like this
Untitled.png
I need to know what the value of the number of choices is so that I can use it, but I wouldn't even know where to start... Any suggestions would be greatly appreciated. ^_^

User avatar
Qlara
Regular
Posts: 80
Joined: Fri Nov 28, 2014 10:22 am
Completed: Carmilla
Skype: kantonija
itch: visualgothic
Location: Berlin
Contact:

Re: Changing the yanchor (in screens.rpy) using if statement

#2 Post by Qlara »

You want:
if (the number of dialogue choices) is 2, make the (value) of (yanchor) (-1.5)
or
if (a) equals 2, then set (y-anchor) to (value)

What you did was:
if (y-anchor) equals (value) or (value) or (value)

Unfortunately, I am better at pseudo- than actual code, so there may be some mistakes here, but you definitely need a variable for (the number of dialogue choices) that holds a number (or integer) so that you can compare it to 2.
Let's call (the number of dialogue choices) "ndc" and give it a default value of 1.

Code: Select all

default ndc = 1
If you have two dialogue choices, set that to 2:

Code: Select all

$ ndc = 2
now you can compare (== checks equality) and assign value (=)

Code: Select all

if ndc == 2:
    yanchor = -1.5
However, are you sure about all this?
What exactly are you trying to achieve? You do know that your choice box can/will adjust automatically?
Are you sure you want to mess with the yanchor of all things ? Of the vbox? :shock: This seems suspicious since you already set ypos.
Perhaps I'm misreading this, and you do have a reason, in that case it would help if you could specify some more. Or, you might just want to look up anchor and position. Its super simple, and everything will suddenly become bright and clear.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot]