Change variable when mouse hover.

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
Renpie
Newbie
Posts: 14
Joined: Sat Jul 11, 2015 9:49 am
Contact:

Change variable when mouse hover.

#1 Post by Renpie » Sat Jul 18, 2015 6:45 am

Hello,

Is it possible to change some variable if you hover over something?

Lets say "target" is 0 by default and there's 2 pictures on screen. When you hover over picture 1 it changes "target" value to 1, but if you leave picture 1, it stays 1 and only by hovering picture 2 it changes "target" to 2 and visa versa. Is there a way?

I tried mousearea, but it doesn't allow this

Code: Select all

            mousearea:
                area (5, 295, 175, 50)
                hovered Show("buttons_skip")
                unhovered Hide("buttons_skip")
                action $ target = 1
if this is not possible to do, i have to make so many screens for every single button then..

User avatar
mobychan
Veteran
Posts: 275
Joined: Fri Apr 24, 2015 6:31 am
Projects: The Chosen - Sakura Pink & Gentian Blue
Organization: Foresoft
Location: Germany
Contact:

Re: Change variable when mouse hover.

#2 Post by mobychan » Sat Jul 18, 2015 6:50 am

I guess you're looking for SetVariable?

Code: Select all

SetVariable("target", 1)

User avatar
Renpie
Newbie
Posts: 14
Joined: Sat Jul 11, 2015 9:49 am
Contact:

Re: Change variable when mouse hover.

#3 Post by Renpie » Sat Jul 18, 2015 7:06 am

mobychan wrote:I guess you're looking for SetVariable?

Code: Select all

SetVariable("target", 1)
It gives error if i try to put that in mousearea.

Code: Select all

File "game/script.rpy", line 34: u'action' is not a keyword argument or valid child for the mousearea statement.
    action SetVariable("target", 1)

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

Re: Change variable when mouse hover.

#4 Post by Alex » Sat Jul 18, 2015 7:34 am

You need to use it for the hovered property, like

Code: Select all

mousearea:
                area (5, 295, 175, 50)
                hovered [Show("buttons_skip"), SetVariable("target", 1)]
                unhovered Hide("buttons_skip")
http://www.renpy.org/doc/html/screens.html#sl-mousearea

User avatar
Renpie
Newbie
Posts: 14
Joined: Sat Jul 11, 2015 9:49 am
Contact:

Re: Change variable when mouse hover.

#5 Post by Renpie » Sat Jul 18, 2015 8:32 am

Alex wrote:You need to use it for the hovered property, like

Code: Select all

mousearea:
                area (5, 295, 175, 50)
                hovered [Show("buttons_skip"), SetVariable("target", 1)]
                unhovered Hide("buttons_skip")
http://www.renpy.org/doc/html/screens.html#sl-mousearea
Nice, this does the trick, but for some reason button detection is very slow with mousearea. Most of time i have to pass over the button twice to make it show itself.

Anyway, thanks.

Post Reply

Who is online

Users browsing this forum: No registered users