Is it possible to set the values of two variables with the same button?
I have a simple inventory system and I want to have it so that when the player uses an item it changes a variable (say he's hp or mp) and then have the item disappear from the inventory (since it was used).
But the action propriety only allows one variable to be changed.
Is there a way around this?
Setting two variables with one button?
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.
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.
-
- Regular
- Posts: 33
- Joined: Sat Mar 04, 2017 8:19 am
- Contact:
- IrinaLazareva
- Veteran
- Posts: 399
- Joined: Wed Jun 08, 2016 1:49 pm
- Projects: Legacy
- Organization: SunShI
- Location: St.Petersburg, Russia
- Contact:
Re: Setting two variables with one button?
it is possible to add several functions on one action
for example
for example
Code: Select all
textbutton "Press Me" action SetVariable(hp', hp+1), SetVariable('mp', mp+1), SetVariable('var3', 0) #etc...
-
- Regular
- Posts: 33
- Joined: Sat Mar 04, 2017 8:19 am
- Contact:
Re: Setting two variables with one button?
I see. I didn't know that )IrinaLazareva wrote: ↑Sun Jan 14, 2018 7:11 am it is possible to add several functions on one action
for exampleCode: Select all
textbutton "Press Me" action SetVariable(hp', hp+1), SetVariable('mp', mp+1), SetVariable('var3', 0) #etc...
Thank you very much
- 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: Setting two variables with one button?
Is this working?IrinaLazareva wrote: ↑Sun Jan 14, 2018 7:11 amCode: Select all
textbutton "Press Me" action SetVariable(hp', hp+1), SetVariable('mp', mp+1), SetVariable('var3', 0) #etc...
I've seen usually lists of actions to do this, with []
An action may also be a list of actions, in which case the actions in the list are run in order.
From the doc: https://www.renpy.org/doc/html/screen_a ... ml#actions
Code: Select all
textbutton "Press Me" action [SetVariable('hp', hp+1), SetVariable('mp', mp+1), SetVariable('var3', 0)]
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)
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)
- IrinaLazareva
- Veteran
- Posts: 399
- Joined: Wed Jun 08, 2016 1:49 pm
- Projects: Legacy
- Organization: SunShI
- Location: St.Petersburg, Russia
- Contact:
Re: Setting two variables with one button?
Yes. It is.
Usually, I use [] - sign only if it is necessary to make transfer of a line.
Code: Select all
textbutton "" action [Show(),
SetVariable(),
Function(),
]
P.S. Though I can be mistaken. I don't claim that it is correct. Just it works. O:)
- Ocelot
- Lemma-Class Veteran
- Posts: 2407
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Setting two variables with one button?
Current implementation works woth any iterable containing Actions. Tuple in this case.
< < insert Rick Cook quote here > >
Who is online
Users browsing this forum: Majestic-12 [Bot]