Displaying a window for clues and affection meter.

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.
Message
Author
User avatar
SilverxBlue
Miko-Class Veteran
Posts: 962
Joined: Sat Jan 01, 2011 1:22 pm
Completed: Caught in Between: A childhood prologue
Projects: MDLS, Alice Hunt(Temporarily on-hold), The Guardian's Spell and one other unannounced thing.
Location: Philippines
Contact:

Displaying a window for clues and affection meter.

#1 Post by SilverxBlue » Fri Jun 03, 2011 2:04 am

Okay, I might sound like a total noob for this but I really need help. I planned on adding some sort of button wherein if you click it, a window where all the clues and the character's affection meter will appear... Kinda like a planner/diary/notebook/whatever where one page shows the clues then another page shows the affection meter of the obtainable characters.
I've been searching like hell of what code to use but i'm not really sure of the things I've found, so can anyone give me a proper link. :)
Please and thank you! ^^
Image Image
"A fool who doesn't think is more foolish than a fool who foolishly thinks." - Franziska Von Karma
Weeeeeee~
不愉快です !!!

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: Displaying a window for clues and affection meter.

#2 Post by Camille » Fri Jun 03, 2011 10:27 am

I think a lot of people like using overlays, but I prefer using screens, which make things really easy. XD This is basically the code that I'm using in my game, plus comments.

Code: Select all

screen button: # This shows the button. In your script, to have the button show up, just type in "show screen button" somewhere.
    vbox xalign 0.1 yalign 0.1:
        textbutton "Show stats" action ui.callsinnewcontext("stats_screen") # basically will call the label "stats_screen"
    # you can also use an image button:
    imagebutton:
                idle "button_idle.png" # image shown when button is idle
                hover "button_hover.png" # image shown when button is hovered over
                action ui.callsinnewcontext("stats_screen") # does the same thing as the text button

label stats_screen:
    scene stats_bg
    python:
        
        ui.hbox()
        
        # Column 1
        ui.vbox(xpos=0, ypos=0, xanchor='left', yanchor='top') # this positions the text
        # THIS IS WHERE YOU WOULD PUT ALL YOUR TEXT/CODE TO SHOW THE STATS/CLUES/WHATEVER here's a sample #
        ui.text("%d points"%intelligence) # would show up as "### points", with ### being whatever number the variable is set to at that point in time

        ui.close() # for the vbox
        
        ui.close() # for the hbox
        
        ui.textbutton("Return", clicked=ui.returns(("goback")) # back to the game!
        ui.imagebutton("return.png", "return_hover.png", clicked=ui.returns("goback"), ypos=0, xpos=0) # same as above, only an image button
        
    $ picked = ui.interact()
    if picked == "goback":
        return
Hope this helps!
Last edited by Camille on Fri Aug 05, 2011 1:18 am, edited 2 times in total.

User avatar
SilverxBlue
Miko-Class Veteran
Posts: 962
Joined: Sat Jan 01, 2011 1:22 pm
Completed: Caught in Between: A childhood prologue
Projects: MDLS, Alice Hunt(Temporarily on-hold), The Guardian's Spell and one other unannounced thing.
Location: Philippines
Contact:

Re: Displaying a window for clues and affection meter.

#3 Post by SilverxBlue » Sat Jun 04, 2011 8:24 am

Ohhhh thanks! I'll try this out as soon as my laptop returns. But if something goes wrong, I'll ask some questions again.
I hope you won't mind. XD
Image Image
"A fool who doesn't think is more foolish than a fool who foolishly thinks." - Franziska Von Karma
Weeeeeee~
不愉快です !!!

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: Displaying a window for clues and affection meter.

#4 Post by Camille » Sat Jun 04, 2011 10:10 am

No problem. XD I'll help as much as I can... All of my coding generally involves the abuse of screens and if statements, though.

User avatar
SilverxBlue
Miko-Class Veteran
Posts: 962
Joined: Sat Jan 01, 2011 1:22 pm
Completed: Caught in Between: A childhood prologue
Projects: MDLS, Alice Hunt(Temporarily on-hold), The Guardian's Spell and one other unannounced thing.
Location: Philippines
Contact:

Re: Displaying a window for clues and affection meter.

#5 Post by SilverxBlue » Tue Jun 21, 2011 8:22 am

Okay, so I finally had the chance to try it out.
My mind finally got tired with all the writing!
It worked out but now I wanted to ask three things.
Sorry if the answers are too obvious, it's really my first time trying this.
How would you make the clue appear once you've seen it?
Example.
"So he is the blah blah blah" then it would go...
"Clue added to note" or something like that.
The second thing is I finally figured out the affection thingy and what if I want to show it through Image format?
Example is if they have like say, ten affection points, Five hearts would show up below a character image and the character image is already blushing.
I know this one relies on the if statements but how exactly could I put the images?
and last, how do you make another page?
Like one page for the affection and one page for the clues.
Again, I'm so sorry with all the stupid questions... DX
Image Image
"A fool who doesn't think is more foolish than a fool who foolishly thinks." - Franziska Von Karma
Weeeeeee~
不愉快です !!!

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: Displaying a window for clues and affection meter.

#6 Post by Camille » Tue Jun 21, 2011 11:27 am

- I'd make a variable like:

Code: Select all

init:

    $ clue_1_seen = False
Then during the scene where you see this clue or whatever, set that variable to True. Then make some code that's like IF TRUE, display the text CLUE ADDED TO NOTE. I have something like this for whenever you receive a new letter in MJ. Simple, but effective.

- Okay I'd probably do if statements for this, too... Like if CHARACTER_POINTS > 10 and if CHARACTER_POINTS < 20 (ie: between 10 and 20), display 5 hearts and the character image is blushing. You can just use the same {image} tag that you use for when you want to embed an image into dialogue, if I remember correctly. Then every time you want the hearts/character image displayed to change, just make another set of if statements for every threshold. Does that make sense? If you want to make a bar for this, don't bother asking me because I have noooo idea how to translate points into a bar image. XD; I'm not using the DSE, so I have to make up all this stuff myself using what I do know.

- For making another page, just make another label. I already gave you the label code for the stats, so here's an example one for clues:

Code: Select all

label clues_screen:
    scene clues_bg
    python:
        
        ui.hbox()
        
        # Column 1
        ui.vbox(xpos=0, ypos=0, xanchor='left', yanchor='top') # this positions the text
        # THIS IS WHERE YOU WOULD PUT ALL YOUR TEXT/CODE TO SHOW THE STATS/CLUES/WHATEVER here's a sample #
        ui.text("CLUES HERE")

        if clue_1_seen == True:
            ui.text("CLUE 1 HERE")

        ui.close() # for the vbox
        
        ui.close() # for the hbox
        
        ui.textbutton("Return", clicked=ui.returns(("goback")) # back to the game!
        ui.imagebutton("return.png", "return_hover.png", clicked=ui.returns("goback"), ypos=0, xpos=0) # same as above, only an image button
        
    $ picked = ui.interact()
    if picked == "goback":
        return
Of course, when you do a button or whatever, you'd change the action ui.callsinnewcontext("stats_screen") part so it'd be clues_screen instead. Something like that. Hope this helps!
Last edited by Camille on Fri Aug 05, 2011 1:18 am, edited 1 time in total.

User avatar
SilverxBlue
Miko-Class Veteran
Posts: 962
Joined: Sat Jan 01, 2011 1:22 pm
Completed: Caught in Between: A childhood prologue
Projects: MDLS, Alice Hunt(Temporarily on-hold), The Guardian's Spell and one other unannounced thing.
Location: Philippines
Contact:

Re: Displaying a window for clues and affection meter.

#7 Post by SilverxBlue » Tue Jun 21, 2011 10:57 pm

Thank you so so much, you've been a really great help! ^^
Image Image
"A fool who doesn't think is more foolish than a fool who foolishly thinks." - Franziska Von Karma
Weeeeeee~
不愉快です !!!

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: Displaying a window for clues and affection meter.

#8 Post by Camille » Tue Jun 21, 2011 11:14 pm

Always glad to be of service. :3

Blueoriontiger
Newbie
Posts: 6
Joined: Thu Aug 04, 2011 7:28 pm
Contact:

Re: Displaying a window for clues and affection meter.

#9 Post by Blueoriontiger » Thu Aug 04, 2011 9:22 pm

Camille, I keep getting a syntax error with the first line of your code "screen button". It keeps telling me that no matter what I do. Where does this section go exactly?
screen button: # This shows the button. In your script, to have the button show up, just type in "show screen button" somewhere.
vbox xalign 0.1 yalign 0.1:
textbutton "Show stats" action ui.callsinnewcontext("stats_screen") # basically will call the label "stats_screen"
# you can also use an image button:

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: Displaying a window for clues and affection meter.

#10 Post by Camille » Thu Aug 04, 2011 11:57 pm

Well, the code can go anywhere. I would probably put it in screens.rpy, though, just to be organized. I did accidentally screw up the textbutton in the code (it should be a ui.textbutton, etc.) but I don't know why the first line is getting an error. 0_o What does the syntax error say?

Blueoriontiger
Newbie
Posts: 6
Joined: Thu Aug 04, 2011 7:28 pm
Contact:

Re: Displaying a window for clues and affection meter.

#11 Post by Blueoriontiger » Fri Aug 05, 2011 12:25 am

It just points to the end of the line where the colon is and says something to the effect of statement expected.

screen button:
..................^

I'm also getting an error with this line now. Says syntax error when parsing the python expression. There were no brackets or comma originally, and I was getting more errors too until I added those.
textbutton("Show stats", action=ui.callsinnewcontext("stats_screen")) . Arrow points to the space between action and ui no matter what I put in there.


I'm using version 6.12.1.1520, so I don't know if that has to do with anything.

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: Displaying a window for clues and affection meter.

#12 Post by Camille » Fri Aug 05, 2011 12:45 am

Are you indenting all the lines properly? The line after screen button: should be indented four spaces over.

Code: Select all

("Show stats", action=ui.callsinnewcontext("stats_screen"))
That isn't anything, lol. I did say that it should be a ui.textbutton (I was using the screen syntax on accident in the original code) so it should be

Code: Select all

ui.textbutton("Show Stats", clicked=ui.callsinnewcontext("stats_screen"))

Blueoriontiger
Newbie
Posts: 6
Joined: Thu Aug 04, 2011 7:28 pm
Contact:

Re: Displaying a window for clues and affection meter.

#13 Post by Blueoriontiger » Fri Aug 05, 2011 12:54 am

Hm, okay. XD Looks indented properly. Just put in your edited code, now getting this? o.O
File "game/script.rpy", line 15: Expected a screen language statement.
ui.textbutton("Show Stats", clicked=ui.callsinnewcontext("stats_screen"))
Arrow points to right after ui.

I'll just "dump" the entire section I'm working with to help with what's going wrong. I'm not sure what's going on. >.<
screen button: # This shows the button. In your script, to have the button show up, just type in "show screen button" somewhere.
vbox xalign 0.1 yalign 0.1
ui.textbutton("Show Stats", clicked=ui.callsinnewcontext("stats_screen")) # basically will call the label "stats_screen"
Also I'm not sure why the post is not holding my indentions, but the bottom two lines are indented four spaces.

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: Displaying a window for clues and affection meter.

#14 Post by Camille » Fri Aug 05, 2011 1:05 am

Oh, I got confused as to which part you were trying to edit. The reason the post isn't holding your indentations is because you're using "quote", not "code". If everything's indented correctly then this should all work:

Code: Select all

screen button: # This shows the button. In your script, to have the button show up, just type in "show screen button" somewhere.
    vbox xalign 0.1 yalign 0.1:
        textbutton "Show stats" action ui.callsinnewcontext("stats_screen") # basically will call the label "stats_screen"
You left off the colon after the vbox line.

Blueoriontiger
Newbie
Posts: 6
Joined: Thu Aug 04, 2011 7:28 pm
Contact:

Re: Displaying a window for clues and affection meter.

#15 Post by Blueoriontiger » Fri Aug 05, 2011 1:10 am

O_O Whatever you did made it work. At least there's a button on the screen now. (Now just have to figure out the code for what I want on the other screen) XD Thanks. :)

Post Reply

Who is online

Users browsing this forum: Bing [Bot]