[solved] How to make a separate button to this function (textbutton/imagebutton)?

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
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

[solved] How to make a separate button to this function (textbutton/imagebutton)?

#1 Post by Nanahs »

I'm using this code to let the player choose their bedroom background:

Code: Select all

default bdr = 'a'
image bedroom = 'bedroom[bdr].jpg'

screen chosebedroom():
    text 'Choose your bedroom.' align(.7, .3)
    hbox at truecenter:
        spacing 7
        imagebutton idle im.FactorScale('bedrooma.jpg', .2) action SetVariable('bdr', 'a'), Return()
        imagebutton idle im.FactorScale('bedroomb.jpg', .2) action SetVariable('bdr', 'b'), Return()
        imagebutton idle im.FactorScale('bedroomc.jpg', .2) action SetVariable('bdr', 'c'), Return()
        imagebutton idle im.FactorScale('bedroomd.jpg', .2) action SetVariable('bdr', 'd'), Return()  
It looks something like this:

Image

When the player clicks on the image, the game sets it as "image bedroom."

But I wanted to do something like this:

Image

I know that would be more "trouble", since I'd have to create more screens. But I really want to have this "Background" button under each image.

So basically I'd have to create a screen (for each image) with a textbutton "Background", right?
I tried doing this but I failed at "converting" the information from the imagebutton to the textbutton.
It's also necessary to add a position to the textbutton to stay at the right place.

What's the order of the text "Background", position, action, etc? I tried many different ways and got the "not a keyword argument or valid child for the textbutton statement." error.

Thanks.
Last edited by Nanahs on Fri Jan 18, 2019 4:49 pm, edited 1 time in total.

Viarch
Newbie
Posts: 1
Joined: Mon Jun 05, 2017 5:55 am
Contact:

Re: How to make a separate button to this function (textbutton/imagebutton)?

#2 Post by Viarch »

sorry for my english, you just want to add some text to imagebuttons ? if yes, you can add text directly to images.

User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: How to make a separate button to this function (textbutton/imagebutton)?

#3 Post by Nanahs »

Viarch wrote: Wed Jan 09, 2019 6:13 pm sorry for my english, you just want to add some text to imagebuttons ? if yes, you can add text directly to images.
Hello! Actually I'm trying to discover how to adjust the action from that imagebutton to a textbutton.

I know this one:

Code: Select all

textbutton _("choice") action SetField(persistent, "variable", "value")
I just don't know how to use it with the images yet.

But thanks for trying to help :)

ps: English is not my first language too :lol:

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: How to make a separate button to this function (textbutton/imagebutton)?

#4 Post by Imperf3kt »

The action should be identical. A textbutton is a button, and am imagebutton is a button. Any action a textbutton can use, an imagebutton can too, since they're both buttons.

Alternatively, you could use a button and supply both an image and text (if desired) and use it in the same way.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: How to make a separate button to this function (textbutton/imagebutton)?

#5 Post by Remix »

Code: Select all

textbutton "The Text Bit":
    # maybe some styles or style name to adjust positions of each part

    idle_background "background_image.png"
    # maybe with hover_ etc etc # this goes below the text

    idle_foreground "bedrooma.png"
    # maybe with hover_ as well etc # this goes above

    focus_mask "some_image_to_define_mask_area.png"
    # no hover_ needed # this isn't shown
You can use Frame() or Transform() for bg/fg/focus too
Frameworks & Scriptlets:

User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: How to make a separate button to this function (textbutton/imagebutton)?

#6 Post by Nanahs »

Imperf3kt wrote: Wed Jan 09, 2019 9:18 pm The action should be identical. A textbutton is a button, and am imagebutton is a button. Any action a textbutton can use, an imagebutton can too, since they're both buttons.

Alternatively, you could use a button and supply both an image and text (if desired) and use it in the same way.
Oh, ok. I just got confused because in this case:

Code: Select all

        imagebutton idle im.FactorScale('bedrooma.jpg', .2) action SetVariable('bdr', 'a'), Return()
The button is the image (that's why it's called imagebutton, right? :lol: ).
I don't know how to make a texbutton that would make "bedrooma.jpg" "SetVariable". Do you know what I mean? My explanation is confusing :oops: :lol:

If I do:

Code: Select all

        textbutton idle im.FactorScale('bedrooma.jpg', .2) action SetVariable('bdr', 'a'), Return()
It's not simply like that. Or is it? :?: Where would I write "Background"? I'm confused about how do I combine the text "Background" with the action, and show it instead of showing the image.
The image I'd show normally as a "show bedrooma", so that the person you'd now that when clicking on the "Background" under that image, that would be the one they' are choosing.

OMG :?: :?: :lol:

User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: How to make a separate button to this function (textbutton/imagebutton)?

#7 Post by Nanahs »

Remix wrote: Thu Jan 10, 2019 6:00 am

Code: Select all

textbutton "The Text Bit":
    # maybe some styles or style name to adjust positions of each part

    idle_background "background_image.png"
    # maybe with hover_ etc etc # this goes below the text

    idle_foreground "bedrooma.png"
    # maybe with hover_ as well etc # this goes above

    focus_mask "some_image_to_define_mask_area.png"
    # no hover_ needed # this isn't shown
You can use Frame() or Transform() for bg/fg/focus too
Thank you so much!
I just don't know, what "focus_mask" is for? And "idle_background "background_image.png" is any image that I just set as a "standard" background?
Sorry, those terms confuse me a little. I always have to search the meaning of "idle" because I forget :oops: :lol: (English is not my language).

Post Reply

Who is online

Users browsing this forum: No registered users