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.
-
henvu50
- Veteran
- Posts: 322
- Joined: Wed Aug 22, 2018 1:22 am
-
Contact:
#1
Post
by henvu50 » Sun Jun 20, 2021 7:30 pm
How to put if conditional statements in action Setvariable? In what part of the Renpy documentation is this covered?
Setting the variable is the easy part:
Code: Select all
action SetVariable("thatVar", thatVar-1)
But how do you check if a boolean variable is true or false, before incrementing or decrementing a variable using setvariable?
Code: Select all
# i want thatVar to only decrement if someBool == true, but can't figure out the syntax
action SetVariable("thatVar", If(someBool == True, thatVar-1))
Last edited by
henvu50 on Mon Jun 21, 2021 4:14 pm, edited 1 time in total.
-
Imperf3kt
- Lemma-Class Veteran
- Posts: 3636
- Joined: Mon Dec 14, 2015 5:05 am
- Location: Your monitor
-
Contact:
#2
Post
by Imperf3kt » Sun Jun 20, 2021 9:17 pm
Put the logic in the button, not the action.
Alternatively, you could make the action call a label and then put your conditional statement in there.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project:
GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Users browsing this forum: No registered users