[SOLVED] imagebutton hover + hovered not showing anything.

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
Skaiya
Regular
Posts: 95
Joined: Tue Sep 25, 2012 5:42 pm
Projects: My Lovely Pastry, Crystal Diamonds Shatter, IWSTBMTB
Tumblr: skaiya-art
Deviantart: skaiyaart
Location: The Netherlands
Contact:

[SOLVED] imagebutton hover + hovered not showing anything.

#1 Post by Skaiya »

Sorry for being here once again.
Whenever I try to use the search here the page just won't load and will act as if I have no internet connection.
With Google I haven't gotten that far either.

Alright this time my question should be less of a hassle.

I have a "simple" inventory system.
The player can hold 3 items in total.
I edited my initial question since I managed to get that stuff to work HOWEVER.
This last part is a mystery to me.

library.rpy

Code: Select all

default carry = 0
script.rpy

Code: Select all

$ items = []
$ vial = item("Vial", "assets/items/vial_min.png", "assets/items/vial_min_hover.png", "A vial, no idea what is in it.")

if carry < 3: 
        $ items.append(vial)
        $ carry += 1
Screen.rpy

Code: Select all

init python:
    class item:
        def __init__(self, name, picture, Hover, description):
            self.name = name
            self.picture = picture
            self.Hover = Hover
            if description == "":
                self.description = "Item."
            else:
                self.description = description
                
screen description:
    hbox:
        text i.name
        xalign 0.5
        ypos 370
    hbox:
        text i.description
        xpos 445
        ypos 406

screen inventory_screen:
    modal True
    add "gui/overlay/inv_bg.png"
    imagebutton:
            idle "gui/button/inventory.png"
            hover "gui/button/inventory_hover.png"
            xpos 10
            ypos 10
            action Hide("inventory_screen")
            
    grid 3 1:
       
        spacing 35
        xpos 455
        ypos  125

        for i in items:
            imagebutton: 
                    idle i.picture #if I switch this one with i.Hover it shows i.Hover
                    hover i.Hover 
                    hovered Show("description")
                    unhovered Hide("description")
        for i in items:
            null
            null
The problem is, hover doesn't work and hovered doesn't work.
As if it doesn't see the imagebutton.

Adding the links of the pages I visited:
Topic 1
Topic 2
Topic 3 that features way too many things that I don't need and I tried to dissect it but got stuck
Topic 4

Thanks in advance once again and I am sorry for the dumb questions I am asking.

How it got solved:

Code: Select all

imagebutton: 
	idle i.picture
	hover i.Hover
	hovered Show("description", i=i) 
	unhovered Hide("description")
	action NullAction()
Last edited by Skaiya on Tue Feb 13, 2018 10:16 pm, edited 7 times in total.
My dA
My Tumblr
Currently working on:
My Lovely Pastry, Crystal Diamonds Shatter, IWSTBMTB.

User avatar
Skaiya
Regular
Posts: 95
Joined: Tue Sep 25, 2012 5:42 pm
Projects: My Lovely Pastry, Crystal Diamonds Shatter, IWSTBMTB
Tumblr: skaiya-art
Deviantart: skaiyaart
Location: The Netherlands
Contact:

Re: imagebutton hover + hovered not showing anything.

#2 Post by Skaiya »

Bump, I managed to get some things working when tweaking codes but I don't know why it won't show hover and hovered.
My dA
My Tumblr
Currently working on:
My Lovely Pastry, Crystal Diamonds Shatter, IWSTBMTB.

irredeemable
Regular
Posts: 78
Joined: Thu Feb 08, 2018 7:57 am
Contact:

Re: imagebutton hover + hovered not showing anything.

#3 Post by irredeemable »

Couple of things: your buttons won't respond to hover events unless they have an action. If you don't want them to actually do anything when clicked use NullAction(). If your description screen did show it would crash as the variable 'i' is local to inventory_screen--you would need to change description so that it takes an argument(lets just stick with 'i') and change Show("description") to Show("description", i=i). Also, there is a tool tip system you can use rather than creating your own screen if all you want to do is display text.

User avatar
Skaiya
Regular
Posts: 95
Joined: Tue Sep 25, 2012 5:42 pm
Projects: My Lovely Pastry, Crystal Diamonds Shatter, IWSTBMTB
Tumblr: skaiya-art
Deviantart: skaiyaart
Location: The Netherlands
Contact:

Re: imagebutton hover + hovered not showing anything.

#4 Post by Skaiya »

@irredeemable I love you.
It works now.
I actually didn't know about the buttons so thank you for that!
All the threads I visited didn't show any of that.
I actually went with my own screen instead of a tool tip on purpose and it works fine now.
Thank you so much!

Tbf I had a whole different question here since a lot of things just didn't want to work at all.
I used the for i in range(len(items)): thing first to keep up with how many items I had and..
But it had trouble showing the image.
I changed everything to having to change on my own which works.
Probably super inefficient but it works
My dA
My Tumblr
Currently working on:
My Lovely Pastry, Crystal Diamonds Shatter, IWSTBMTB.

irredeemable
Regular
Posts: 78
Joined: Thu Feb 08, 2018 7:57 am
Contact:

Re: [SOLVED] imagebutton hover + hovered not showing anything.

#5 Post by irredeemable »

You're welcome.

for i in items is much more efficient than for i in range(len(items)). You could use the latter(though I can't imagine why you'd want to) but 'i' would be an integer equal to the index, not an item, so the code would change to

Code: Select all

idle items[i].picture
etc.

Just noticed the other question regarding the quick menu: modal prevents you from interacting with any screens that are beneath the modal screen. The zorder of quick_menu is 100 so to prevent the user from interacting with the quick menu in your screen you'd have to set the zorder higher than 100.

User avatar
Skaiya
Regular
Posts: 95
Joined: Tue Sep 25, 2012 5:42 pm
Projects: My Lovely Pastry, Crystal Diamonds Shatter, IWSTBMTB
Tumblr: skaiya-art
Deviantart: skaiyaart
Location: The Netherlands
Contact:

Re: [SOLVED] imagebutton hover + hovered not showing anything.

#6 Post by Skaiya »

@irredeemable, hahah I just fixed the zorder one, I totally forgot that one existed until I looked at some of my other screens but thanks again!
Honestly, really appreciate you taking your time to reply :mrgreen:

As for the i in range, I saw that one because of this:

Code: Select all

for i in range(len(inventory)):
            imagebutton: 
               idle inventory[i][0] 
               hover inventory[i][1] 
               hovered Show("description", item = i) 
               unhovered Hide("description") action Jump("itemmenu")

        for i in range(8 - len(inventory)):
            null
            
if len(inventory) < 8:
        $ inventory.append("001.png", "002.png", "Insert description here")
Then tried to modify it to my code but if you think what I have now is more efficient then I will keep that.
My dA
My Tumblr
Currently working on:
My Lovely Pastry, Crystal Diamonds Shatter, IWSTBMTB.

Post Reply

Who is online

Users browsing this forum: BadMustard, Ocelot