About text buttons

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
Jelenie08
Newbie
Posts: 15
Joined: Tue Apr 19, 2011 5:49 am
Contact:

About text buttons

#1 Post by Jelenie08 » Tue Apr 19, 2011 6:00 am

How do you make a text button and make it appear on the screen all the time? Also, how do I make it open a window with statistics when clicked? Sorry for asking too many questions. Thanks! :D

shuen
Regular
Posts: 72
Joined: Tue Mar 22, 2011 2:36 pm
Contact:

Re: About text buttons

#2 Post by shuen » Tue Apr 19, 2011 8:09 am

Jelenie08 wrote:How do you make a text button and make it appear on the screen all the time?
It is easy If you just want to create a button.

Code: Select all

init python:
    def display_button():
           ui.textbutton("This is Your Button",clicked=##do something)
    config.overlay_functions.append(display_button)
Jelenie08 wrote:Also, how do I make it open a window with statistics when clicked?
This question is so common...I advise you search the forum before asking question.
The Wiki already has similar example, You just need to modifty the code.
http://www.renpy.org/wiki/renpy/doc/coo ... _Game_Menu
Image
.Traditional Chinese Site.
~Illustrator+Graphic/Web Designer~

Jelenie08
Newbie
Posts: 15
Joined: Tue Apr 19, 2011 5:49 am
Contact:

Re: About text buttons

#3 Post by Jelenie08 » Tue Apr 19, 2011 8:38 am

I've already visited that. I just couldn't understand it. But now I know how to create a button and make it appear all the time. I was just confused that time. Thanks anyway. But I still don't know why it looks like this:
printscreen.png
I mean the screen is black. There is supposed to be an image map. I typed this code under the init python:

Code: Select all

init python:
    def display_stat():
        if show_display_stat:
            ui.vbox()
            ui.text("Money: $ %s" %money)
            ui.text("HP: %s" %hp)
            ui.text("Day %s" %day)
            ui.textbutton("Statistics", clicked=ui.returns("stats"))
            ui.close()
    config.overlay_functions.append(display_stat)
And this under a label:

Code: Select all

label homemap:
    
    #variables:
    $ hp = 100
    $ day = 1
    $ money = 100
    $ display_stat()
    
    $ show_display_stat = True
        
    $ result = ui.interact()
    
    if result == "stats":
        jump statistics
        
    
    $ do = renpy.imagemap("home1.png", "home2.png", [
        (628, 419, 749, 469, "sleep"),
        (622, 478, 751, 534, "leave"), 
        ], focus="imagemap")
What changes do I need to show the button and the imagemap at the same time?

User avatar
Alera
Miko-Class Veteran
Posts: 649
Joined: Sun Mar 21, 2010 3:20 am
Completed: Tortichki // Zayay
Organization: SHINE
Tumblr: psyalera
Deviantart: psyalera
Contact:

Re: About text buttons

#4 Post by Alera » Tue Apr 19, 2011 9:08 am

Hm...just a quick thought, because now I don't have time to test things and look trough your code:

Which version of RenPy do you have? If it's one of the newest- try using the new screen language for the imagemap.

Image
Games:
❤️ Zayay [Otome?][BxPlayer][NaNo 2013]
❤️ Tortichki [Drag&Drop mini game]

Other games I've worked on:
My Heart's Flame Emissary of Starlight Freedom From Silence Sickness
And many more unannounced/secret projects. (. .)

Jelenie08
Newbie
Posts: 15
Joined: Tue Apr 19, 2011 5:49 am
Contact:

Re: About text buttons

#5 Post by Jelenie08 » Tue Apr 19, 2011 9:27 am

Alera wrote:Hm...just a quick thought, because now I don't have time to test things and look trough your code:

Which version of RenPy do you have? If it's one of the newest- try using the new screen language for the imagemap.

how do you know the version of ren'py you're using?

Jelenie08
Newbie
Posts: 15
Joined: Tue Apr 19, 2011 5:49 am
Contact:

Re: About text buttons

#6 Post by Jelenie08 » Tue Apr 19, 2011 9:27 am

Alera wrote:Hm...just a quick thought, because now I don't have time to test things and look trough your code:

Which version of RenPy do you have? If it's one of the newest- try using the new screen language for the imagemap.

how do you know the version of ren'py you're using?

Jelenie08
Newbie
Posts: 15
Joined: Tue Apr 19, 2011 5:49 am
Contact:

Re: About text buttons

#7 Post by Jelenie08 » Tue Apr 19, 2011 9:27 am

Alera wrote:Hm...just a quick thought, because now I don't have time to test things and look trough your code:

Which version of RenPy do you have? If it's one of the newest- try using the new screen language for the imagemap.

how do you know the version of ren'py you're using?

User avatar
Ellume
Regular
Posts: 36
Joined: Tue Apr 06, 2010 2:57 am
Contact:

Re: About text buttons

#8 Post by Ellume » Tue Apr 19, 2011 9:41 am

I think the simplest way to figure out version is just run Ren'py and look at what it says on the top. Mine says "Ren'Py 6.12.0e Launcher".

User avatar
Alera
Miko-Class Veteran
Posts: 649
Joined: Sun Mar 21, 2010 3:20 am
Completed: Tortichki // Zayay
Organization: SHINE
Tumblr: psyalera
Deviantart: psyalera
Contact:

Re: About text buttons

#9 Post by Alera » Tue Apr 19, 2011 9:42 am

Jelenie08 wrote: how do you know the version of ren'py you're using?
When you launch the program look up in the window bar.

Like- this is what mine shows:
Image
Image
Games:
❤️ Zayay [Otome?][BxPlayer][NaNo 2013]
❤️ Tortichki [Drag&Drop mini game]

Other games I've worked on:
My Heart's Flame Emissary of Starlight Freedom From Silence Sickness
And many more unannounced/secret projects. (. .)

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

Re: About text buttons

#10 Post by Alex » Tue Apr 19, 2011 1:05 pm

Hm, I think the problem is in

Code: Select all

$ result = ui.interact()
It makes your game wait untill you click the button. So, just delete this line to let Ren'py to execute next lines and show you the imagemap. Also, if you need to jump to label "statistic" when button clicked, then change it like

Code: Select all

ui.textbutton("Statistics", clicked=ui.jumps("statistics"))
If you'll do so, you wouldn't need those lines anymore

Code: Select all

if result == "stats":
        jump statistics

Jelenie08
Newbie
Posts: 15
Joined: Tue Apr 19, 2011 5:49 am
Contact:

Re: About text buttons

#11 Post by Jelenie08 » Tue Apr 19, 2011 11:48 pm

Alera wrote:Hm...just a quick thought, because now I don't have time to test things and look trough your code:

Which version of RenPy do you have? If it's one of the newest- try using the new screen language for the imagemap.

Ellume wrote:I think the simplest way to figure out version is just run Ren'py and look at what it says on the top. Mine says "Ren'Py 6.12.0e Launcher".
Alera wrote:
When you launch the program look up in the window bar.

Like- this is what mine shows:
Image
Mine says "Ren'Py 6.11.2b Launcher". Well, I guess I need to download it again. Thank you very much! I'll try that new screen language for imagemaps.
Alex wrote:Hm, I think the problem is in

Code: Select all

$ result = ui.interact()
It makes your game wait untill you click the button. So, just delete this line to let Ren'py to execute next lines and show you the imagemap. Also, if you need to jump to label "statistic" when button clicked, then change it like

Code: Select all

ui.textbutton("Statistics", clicked=ui.jumps("statistics"))
If you'll do so, you wouldn't need those lines anymore

Code: Select all

if result == "stats":
        jump statistics
I tried that ui.jumps() function but an error occurred and says something "'str' not callable..." I guess that has something to do with the version of Ren'py I'm using. Thank you very much!

I'll update this post when it works. Thanks again everyone! :D :D

Jelenie08
Newbie
Posts: 15
Joined: Tue Apr 19, 2011 5:49 am
Contact:

Re: About text buttons

#12 Post by Jelenie08 » Wed Apr 20, 2011 12:32 am

I did what you guys said and it all worked! :) Thank you!

Post Reply

Who is online

Users browsing this forum: Ayael, Google [Bot]