Page 1 of 1

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

Posted: Thu Dec 06, 2018 5:01 pm
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. ^_^

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

Posted: Sat Dec 15, 2018 1:45 am
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.