Multiple if statements action

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
bambino358
Regular
Posts: 26
Joined: Sat Apr 27, 2019 7:17 am
Contact:

Multiple if statements action

#1 Post by bambino358 » Fri Dec 06, 2019 7:33 am

Hello, there is probably easy solution for this one but I cannot figure it out.
I have a hotspot and I need to execute all actions at the same time (one click) if the condition is true. This is my code:

Code: Select all

hotspot (1770, 995, 112, 58):
                if rtenka > 1:
                    action [SetVariable("rtenka", 1), SetVariable("extrapoints",extrapoints + 1)]
                if makeup > 1:
                    action [SetVariable("makeup", 1), SetVariable("extrapoints",extrapoints + 1)]
                if choker > 1:
                    action [SetVariable("choker", 1), SetVariable("extrapoints",extrapoints + 1)]
                if nehty > 1:
                    action [SetVariable("nehty", 1), SetVariable("extrapoints",extrapoints + 1)]
                if naramek > 1:
                    action [SetVariable("naramek", 1), SetVariable("extrapoints",extrapoints + 1)]
But now if for example makeup > 1 and choker > 1 this code execute only action for makeup and then I have to click againt to execute action for choker.
How to do it to execute all action at the same time??

Thank you

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: Multiple if statements action

#2 Post by isobellesophia » Fri Dec 06, 2019 8:45 am

Use if, and the other if, change it to elif and the last one is else.
I am a friendly user, please respect and have a good day.


Image

Image


bambino358
Regular
Posts: 26
Joined: Sat Apr 27, 2019 7:17 am
Contact:

Re: Multiple if statements action

#3 Post by bambino358 » Fri Dec 06, 2019 8:55 am

isobellesophia wrote:
Fri Dec 06, 2019 8:45 am
Use if, and the other if, change it to elif and the last one is else.
Well, I did this:

Code: Select all

hotspot (1770, 995, 112, 58):
                if rtenka > 1:
                    action [SetVariable("rtenka", 1), SetVariable("extrapoints",extrapoints + 1)]
                elif makeup > 1:
                    action [SetVariable("makeup", 1), SetVariable("extrapoints",extrapoints + 1)]
                elif choker > 1:
                    action [SetVariable("choker", 1), SetVariable("extrapoints",extrapoints + 1)]
                elif nehty > 1:
                    action [SetVariable("nehty", 1), SetVariable("extrapoints",extrapoints + 1)]
                else:
                    action [SetVariable("naramek", 1), SetVariable("extrapoints",extrapoints + 1)]
But this code behaves exactly same as the code with only "if"...

When multiple conditions is true I have to click multiple times.

User avatar
deltadidirac
Regular
Posts: 123
Joined: Fri Nov 30, 2018 5:00 am
Projects: Artworks and Comics
Tumblr: deltadidirac
Deviantart: Deltadidirac67
Location: Europe
Contact:

Re: Multiple if statements action

#4 Post by deltadidirac » Fri Dec 06, 2019 10:04 am

bambino358 wrote:
Fri Dec 06, 2019 8:55 am
isobellesophia wrote:
Fri Dec 06, 2019 8:45 am
Use if, and the other if, change it to elif and the last one is else.
Well, I did this:

Code: Select all

hotspot (1770, 995, 112, 58):
                if rtenka > 1:
                    action [SetVariable("rtenka", 1), SetVariable("extrapoints",extrapoints + 1)]
                elif makeup > 1:
                    action [SetVariable("makeup", 1), SetVariable("extrapoints",extrapoints + 1)]
                elif choker > 1:
                    action [SetVariable("choker", 1), SetVariable("extrapoints",extrapoints + 1)]
                elif nehty > 1:
                    action [SetVariable("nehty", 1), SetVariable("extrapoints",extrapoints + 1)]
                else:
                    action [SetVariable("naramek", 1), SetVariable("extrapoints",extrapoints + 1)]
But this code behaves exactly same as the code with only "if"...

When multiple conditions is true I have to click multiple times.
If these different objects are indipendent eache other (that mean that the value of makeup is not influenced by choker or something others in the list; in that case you must check very well if is not some mistake with the values or the conditions BEFORE your" hotspot")

If all it's right perhaps is the way you have used to wrote the code.....
if I remeber well it would be something like that :

Code: Select all

action [SetVariable("makeup", makeup=1), SetVariable("extrapoints",extrapoints+1)]
You must try it , but there is a thing that I don't understand.....
why you repeat the command? all it would be wrote as is... :

Code: Select all

action [SetVariable ( SetVariable("extrapoints",extrapoints+1)]
bye

bambino358
Regular
Posts: 26
Joined: Sat Apr 27, 2019 7:17 am
Contact:

Re: Multiple if statements action

#5 Post by bambino358 » Fri Dec 06, 2019 10:30 am

Ok I have a solution. That code I posted is wrong. All the "if" conditions has to be inside one "Action". I created multiple actions in one hotspot and that doesn't work.

More info here: viewtopic.php?t=45330

Post Reply

Who is online

Users browsing this forum: mold.FF