Screens and variable trouble (SOLVED)

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
User avatar
blueberryblanket
Newbie
Posts: 8
Joined: Thu Mar 22, 2012 4:01 pm
Projects: Amoena Anima
Contact:

Screens and variable trouble (SOLVED)

#1 Post by blueberryblanket » Thu Jun 05, 2014 2:49 pm

I'm having trouble programming screens. I just can never seem to get the hang of them, for some reason.

I have a clock as part of the GUI, that appears like so:

Image

The clock is made of two seperate images, the face and the frame. Right now I have it as a screen, like so:

Code: Select all

screen clock:
        add "ClockFace.png" xanchor 0.5 yanchor 0.5 xpos 1 ypos .1
        add "ClockFrame.png" xanchor 0.5 yanchor 0.5 xpos 1 ypos .1
I also have two variables, $hour and $currenthour. They interact like so:

Code: Select all

if hour == currenthour +1:
            show clockface:
                xanchor 0.5 yanchor 0.5
                xpos 1 ypos .1
                linear 0.5 rotate -72
    if hour == currenthour +2:
            show clockface:
                xanchor 0.5 yanchor 0.5
                xpos 1 ypos .1
                linear 0.5 rotate -144
    if hour == currenthour +3:
            show clockface:
                xanchor 0.5 yanchor 0.5
                xpos 1 ypos .1
                linear 0.5 rotate -216
    if hour == currenthour +4:
            show clockface:
                xanchor 0.5 yanchor 0.5
                xpos 1 ypos .1
                linear 0.5 rotate -288
Now, this code isn't part of my clock screen, since A. linear isn't defined and B. the variables hour and currenthour aren't yet defined. Instead, it's floating about the rest of the code between scenes and is just mucking it up.

My question is, is there a way to include the latter code into a screen? If so, how would one write it? Thanks in advance.
Last edited by blueberryblanket on Thu Jun 05, 2014 5:29 pm, edited 1 time in total.

User avatar
BlueB
Regular
Posts: 57
Joined: Sat Dec 14, 2013 8:11 pm
Projects: Forbidden Arms
Contact:

Re: Screens and variable trouble

#2 Post by BlueB » Thu Jun 05, 2014 3:00 pm

Replying with my new account because I don't watch my old one.
Hey, I'm on deviantArt! Currently doing commissions.

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Screens and variable trouble

#3 Post by Alex » Thu Jun 05, 2014 3:27 pm

Code: Select all

add "ClockFace.png" xanchor 0.5 yanchor 0.5 xpos 1 ypos .1
You've placed the center (xanchor 0.5) of your clock at position 1 pixel from the left side of screen (xpos 1). Try to change the xpos value.

User avatar
BlueB
Regular
Posts: 57
Joined: Sat Dec 14, 2013 8:11 pm
Projects: Forbidden Arms
Contact:

Re: Screens and variable trouble

#4 Post by BlueB » Thu Jun 05, 2014 5:09 pm

I don't think that solves my problem; I changed the position of the clock to xpos 2, but that just changed the location of the screen. I want the clock face to rotate, but for the life of me, can't get it to do so without making it an image rather than an omnipresent screen.
Hey, I'm on deviantArt! Currently doing commissions.

User avatar
Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Screens and variable trouble

#5 Post by Asceai » Thu Jun 05, 2014 5:20 pm

you can use at to apply a transform, or you could add a Transform to the screen, something like this:
add Transform("ClockFace.png", rotate=(hour-currenthour)*72) xanchor 0.5 yanchor 0.5 xpos 1 ypos .1
you may need to add some other stuff to do that and you can't put transform_anchor in a Transform yet so if you need that you'll have to take the at approach but that's a possible starting place.

User avatar
BlueB
Regular
Posts: 57
Joined: Sat Dec 14, 2013 8:11 pm
Projects: Forbidden Arms
Contact:

Re: Screens and variable trouble (SOLVED)

#6 Post by BlueB » Thu Jun 05, 2014 5:28 pm

Thanks a lot! It seems to be working just fine. I'll have to test some possible crash-worthy scenarios, but I think this is a step in the right direction.
Hey, I'm on deviantArt! Currently doing commissions.

Post Reply

Who is online

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