"Clicked" actions

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
Glazed Donuts
Regular
Posts: 121
Joined: Thu Aug 12, 2010 11:47 am
Contact:

"Clicked" actions

#1 Post by Glazed Donuts »

Is there a way to assign several actions to trigger when the user clicks an image button? For example, I would like for a variable to change as well as the image to disappear when the button is clicked:
imagebutton:
idle "sozai/ui/clicked1.png"
hover "sozai/ui/clicked2.png"
clicked (($myPoints += 1), Remove(this)) #Add +1 to $myPoints and delete imagebutton afterwards when you click
xpos 58 ypos 545
xanchor 0 yanchor 0
Would the above be valid? if not, is there a way to do this correctly with RenPy?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: "Clicked" actions

#2 Post by PyTom »

You can use a list as the argument to clicked. For the first part, the obvious thing is to use SetVariable("myPoints", myPoints + 1).

The hiding part is more interesting. Showing/hiding occurs at the screen level, not the button one. So you'd have to set a second variable that controls if the imagebutton is shown or not.

Code: Select all

screen foo:
    if canAddPoint:
        imagebutton:
            idle "sozai/ui/clicked1.png"
            hover "sozai/ui/clicked2.png"
            clicked [ SetVariable("myPoints", myPoints + 1), SetVariable("canAddPoint", False) ]
            xpos 58 ypos 545
            xanchor 0 yanchor 0
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Glazed Donuts
Regular
Posts: 121
Joined: Thu Aug 12, 2010 11:47 am
Contact:

Re: "Clicked" actions

#3 Post by Glazed Donuts »

Thank you, PyTom!! This worked great! This is exactly what I'm looking for!

aoSky
Newbie
Posts: 3
Joined: Fri Apr 20, 2018 9:27 am
Deviantart: yukiren-fx
Contact:

Re: "Clicked" actions

#4 Post by aoSky »

Thank you sooooooo much, exactly what I'm looking for too!!

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: "Clicked" actions

#5 Post by xavimat »

Be careful, aoSky, that post is 7 years old. Better learn how thinks are done today. For example, don't use "clicked" but "action".
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: "Clicked" actions

#6 Post by sculpteur »

Hi guys,
Sorry for the necroposting but I read the last message and I realize i've always wonder what was the difference beteween the old "cliked" and the new "action" in the image map, image button etc.

It's important for me to understand because I have almost ten thousand line of code using the "clicked" fonction and it still works but I want to know if I absolutly need to modify every "cliked" fonction by "action".

If you guys are still around, thank you to tell me what exactly are the differences between this two things.
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: "Clicked" actions

#7 Post by isobellesophia »

You can check it out in the renpy documentation, since this post is old, i think the new action is better and easier rather than a hard, old code.
I am a friendly user, please respect and have a good day.


Image

Image


sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: "Clicked" actions

#8 Post by sculpteur »

isobellesophia wrote: Thu Nov 28, 2019 8:31 am You can check it out in the renpy documentation, since this post is old, i think the new action is better and easier rather than a hard, old code.
Thank you for this advice but your answer is not really relevant since it's seem you don't know anything about it, like me, exept one is newer than the other, like i already said.

As you don't post any link about the renpy documentation maybe than, like me, your didn't read anything about it. Beacause obviously, before posting here , i've searched in the documentation without any result.

I think the explanation I'am looking for is somewhere in a renpy changlog information about the changes between two renpy version but I can't find this anywhere in this : https://www.renpy.org/doc/html/changelog.html. So that's why I wrote this message.
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: "Clicked" actions

#9 Post by PyTom »

There isn't a difference. At some point, clicked was renamed to action, as the action can be triggered in different ways (like using a keyboard key, touch screen, or game controller), other than clicking on it. It also makes the action argument to a button the same as other things that have actions (timers and events come to mind).
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: "Clicked" actions

#10 Post by sculpteur »

Thank you! That make sense! I was suspected something like this since I didn't find any difference in the changelog.
Sorry again for the necroposting ^^
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

Post Reply

Who is online

Users browsing this forum: Andredron, Bing [Bot], Google [Bot]