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.
-
Michael Regal
- Newbie
- Posts: 11
- Joined: Fri Mar 25, 2022 11:38 pm
-
Contact:
#1
Post
by Michael Regal » Thu Apr 07, 2022 3:55 pm
Ladies and gentlemen, is it possible to put an if-else statement into a screen button?
I want to translate this into screen language:
Code: Select all
if (d6roll_1_combat + d6roll_2_combat + d6roll_3_combat + brawn_points) >= (d10roll_1_npc + d10roll_2_npc + d10roll_3_npc + 5 - armorvalue):
$ npchealth -= 1
else:
$ health -= 1
-
Alex
- Lemma-Class Veteran
- Posts: 2981
- Joined: Fri Dec 11, 2009 5:25 pm
-
Contact:
#2
Post
by Alex » Thu Apr 07, 2022 5:57 pm
While you
can do it, you'd better put the game logic outside the screen (in a game loop).
Code: Select all
button:
text "ClickMe!"
if ...:
action ...
else:
action ...
button:
text "ClickMe!"
action If(..., true_action, false_action)
https://www.renpy.org/doc/html/screen_actions.html#If