[Solved]Bypassing imagebutton's hovred-action corelation under condition

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
Doeny
Regular
Posts: 145
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

[Solved]Bypassing imagebutton's hovred-action corelation under condition

#1 Post by Doeny »

Alright, I know the subject is unintelligible, but what I mean is some time ago I realized that if you put an imagebutton's 'action' under a condition, the 'hovered' statement is automatically locked under that condition aswell. Is there a way to bypass it? (without having to write another copy/paste part of the screen)
Last edited by Doeny on Wed Feb 14, 2024 5:22 pm, edited 1 time in total.

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Bypassing imagebutton's hovred-action corelation under condition

#2 Post by m_from_space »

Doeny wrote: Wed Feb 14, 2024 1:59 pm Alright, I know the subject is unintelligible, but what I mean is some time ago I realized that if you put an imagebutton's 'action' under a condition, the 'hovered' statement is automatically locked under that condition aswell. Is there a way to bypass it? (without having to write another copy/paste part of the screen)
Not sure I'm following, you probably mean the "sensitive" property is related to the "action" property. Otherwise please provide an example!

Doeny
Regular
Posts: 145
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

Re: Bypassing imagebutton's hovred-action corelation under condition

#3 Post by Doeny »

m_from_space wrote: Wed Feb 14, 2024 2:57 pm
Doeny wrote: Wed Feb 14, 2024 1:59 pm Not sure I'm following, you probably mean the "sensitive" property is related to the "action" property. Otherwise please provide an example!
Alright, I'll just show it on a part of the code.

Code: Select all

vbox:
    for item in decor_list:
        if item.type == e_type and item.place == e_place and item.slot == 1:
            button:
                if e_place == 2:
                    xpos 230
                    ypos 684
                else:
                    xpos 104
                    ypos 686
                add item.img
                hovered [SetVariable("decor_selected", item), SetVariable("decor_name", item.name), Show("empty_mats_needed")]
                unhovered [SetVariable("decor_name", ""), Hide("empty_mats_needed")]
                if decor_upgrade == 0:
                    if item.wood <= wood and item.rock <= rock and item.fabric <= fabric:
                        if e_place == 1:
                            action [SetVariable("wood", wood - item.wood), SetVariable("rock", rock - item.rock), SetVariable("fabric", fabric - item.fabric), Jump("start")]
                        elif e_place == 2:
                            action [SetVariable("wood", wood - item.wood), SetVariable("rock", rock - item.rock), SetVariable("fabric", fabric - item.fabric), Jump("start")]
                        else:
                            action [SetVariable("wood", wood - item.wood), SetVariable("rock", rock - item.rock), SetVariable("fabric", fabric - item.fabric), Jump("start")]
                else:
                    action Function(renpy.notify, "You can't do that now.")
        if item.type == type and item.place == e_place and item.slot == 2:
        .....
        .....
        .....
Each line here is in fact longer, I just shortened them to don't make a big mess here. But what caught my attention is that if I don't have any e.g. wood, which is a condition above action, I can't hover over certain slots to trigger them.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Bypassing imagebutton's hovred-action corelation under condition

#4 Post by Ocelot »

Button with no action is considered insensitive and does not respond to evens. You have to have an action to have a working button.
< < insert Rick Cook quote here > >

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Bypassing imagebutton's hovred-action corelation under condition

#5 Post by m_from_space »

Doeny wrote: Wed Feb 14, 2024 3:58 pm Each line here is in fact longer, I just shortened them to don't make a big mess here. But what caught my attention is that if I don't have any e.g. wood, which is a condition above action, I can't hover over certain slots to trigger them.
Ocelot already stated it and I want to make it clear: You always need an action inside a button, even if it doesn't do anything. So in case you have no wood etc. insert this:

Code: Select all

action NullAction()

Doeny
Regular
Posts: 145
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

Re: Bypassing imagebutton's hovred-action corelation under condition

#6 Post by Doeny »

m_from_space wrote: Wed Feb 14, 2024 4:50 pm
Doeny wrote: Wed Feb 14, 2024 3:58 pm Each line here is in fact longer, I just shortened them to don't make a big mess here. But what caught my attention is that if I don't have any e.g. wood, which is a condition above action, I can't hover over certain slots to trigger them.
Ocelot already stated it and I want to make it clear: You always need an action inside a button, even if it doesn't do anything. So in case you have no wood etc. insert this:

Code: Select all

action NullAction()
Alright, got it. Thank you guys!

Post Reply

Who is online

Users browsing this forum: Google [Bot]