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.
-
Tessa
- Newbie
- Posts: 16
- Joined: Mon Aug 08, 2022 8:18 pm
-
Contact:
#1
Post
by Tessa » Fri Aug 12, 2022 2:12 pm
Hi all. Struggling a bit with this.
Say I have this bit of code in my screen. I have a button that checks the answer of a puzzle, and an if/then statement follows to either display a continue button if correct (no issue here), or show a "Wrong!" text if incorrect. However, I'd like the "Wrong!" text to disappear after several seconds. I can't seem to find a way to do it. I tried putting the text into another screen, but is there a way to show a screen from within an if/then statement? Everything I've seen requires "action(Show("screen")", but that requires a button press. Any thoughts?
Code: Select all
textbutton "Check Answer":
selected False
action SetScreenVariable("correct", is_matrix_equal(matrix, cmatrix, comparer))
xalign 0.5
yalign 0.8
if correct is None: # not checked yet.
pass
else:
if correct: # if correct then show a text then return after 2 seconds
text "Correct!" xalign 0.9 yalign 0.5
textbutton "CONTINUE" xalign 0.9 yalign 0.55 action Return()
else:
text "Wrong!" xalign 0.9 yalign 0.5
-
plastiekk
- Regular
- Posts: 40
- Joined: Wed Sep 29, 2021 4:08 am
- Discord: plastiekk#3072
-
Contact:
#2
Post
by plastiekk » Sat Aug 13, 2022 9:33 am
You could try it with timers like this:
Code: Select all
else:
timer 0.01 repeat False action Show("wrong", transition=Dissolve(0.3)) # replace this with your text "wrong!" line
screen wrong(): # and add another screen
text "Wrong!" xalign 0.9 yalign 0.5
timer 1.0 repeat False action Hide ('wrong', transition=Dissolve(0.5))
Why on earth did I put the bread in the fridge?
-
laure44
- Regular
- Posts: 60
- Joined: Mon Mar 08, 2021 10:55 pm
- Projects: Arkan'sTower, Gemshine Lorelei!
- Location: France
-
Contact:
#3
Post
by laure44 » Sat Aug 13, 2022 3:40 pm
You can do that in the same screen.
Code: Select all
default show_wrong = True # put that at the beginning of your screen
....
if correct: # if correct then show a text then return after 2 seconds
text "Correct!" xalign 0.9 yalign 0.5
textbutton "CONTINUE" xalign 0.9 yalign 0.55 action Return()
else:
if show_wrong:
timer 2.0 action ToggleScreenVariable("show_wrong")
text "Wrong!" xalign 0.9 yalign 0.5
Users browsing this forum: Bing [Bot], Google [Bot]