Page 1 of 1
[Solved] How can I use it as an "action"?
Posted: Tue Feb 12, 2019 5:00 pm
by Nanahs
If "Coin" starts with 0. Like this:
I wanted a button that would increase the value of coins when being clicked.
Like:
How can I make an "action" that would do that?
I wanted to use an image of coins to create an imagebutton with that "action".
I've only seen this being used, and I have only used, this with "if" statement and menu choice.
So I'm not sure if it's possible.
Thanks.
Re: How can I use it as an "action"?
Posted: Tue Feb 12, 2019 6:03 pm
by Alex
You can make a screen with the button
Code: Select all
textbutton "Get coin" action SetVariable("Coins", Coins+1) # name of variable in quotes (you named it with capital C)
https://www.renpy.org/doc/html/screen_a ... etVariable
https://www.renpy.org/doc/html/screens.html#imagebutton
Re: How can I use it as an "action"?
Posted: Tue Feb 12, 2019 7:05 pm
by trooper6
But as always, remember you should be initializing your variables like this:
rather than like this
Re: How can I use it as an "action"?
Posted: Tue Feb 12, 2019 7:39 pm
by Nanahs
Thank you so much guys!
Re: [Solved] How can I use it as an "action"?
Posted: Wed Feb 13, 2019 9:20 am
by Nanahs
It's working great! Thanks!
Just one question. If I wanted to stablish a limit, how would it be?
Like, if you could only get 10 coins, and after this imagebutton wouldn't add more coins when clicked.
I tried a few things like "max_coins=10", etc and a few other codes, but they didn't work.
Thanks.
Re: [Solved] How can I use it as an "action"?
Posted: Wed Feb 13, 2019 4:59 pm
by Alex
It would be
Code: Select all
textbutton "Get coin" action If(Coins<10, SetVariable("Coins", Coins+1), None)
https://www.renpy.org/doc/html/screen_actions.html#If
Re: [Solved] How can I use it as an "action"?
Posted: Wed Feb 13, 2019 7:04 pm
by Nanahs
Thank you so much!