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.
I'm currently trying to make a QTE that would let you mash a keyboard key to fill up a bar before a timer bar runs out, but the label game is pretty problematic, it always causes an infinite loop exception no matter how I restructure it T-T
Here's my code with comments below:
transform alpha_dissolve:
alpha 0.0
linear 0.5 alpha 1.0
on hide:
linear 0.5 alpha 0 #this fades the bar
screen mash_meter:
text "[mash_points]/[maxmash]" xalign 0.0 yalign 0.05
bar value mash_points range maxmash xalign 0.0 yalign 0.1 xmaximum 200
screen buzz:
if mash:
key "w" action Jump("plus")
screen countdown(timer_jump, time=20):
timer time repeat False action [ Hide('countdown'), Jump(timer_jump) ]
bar value AnimatedValue(0, time, time, time) at alpha_dissolve
label start:
$ mash = False
$ mash_points = 0
$ maxmash = 10
"Game start! (Press \"w\" key)"
label game:
while mash_points <= 10:
show screen mash_meter
show screen countdown("jump_fail")
$ mash = True
show screen buzz #this causes the exception in this current structure, I've changed up the code in this label many times
if mash_points <= 11 and mash_points >= 9: #had to make it look like this since mash_points == 10 causes the exception too
jump passed
else:
jump game
label plus:
$ mash_points += 1
jump game
label jump_fail:
hide screen mash_meter
hide screen countdown
$ mash = False
"Too slow!"
jump start
label passed:
hide screen buzz
hide screen mash_meter
hide screen countdown
$ mash = False
"You win!"
return
screen qte(duration=10.0, goal=50):
default value = 0
hbox:
bar value value range goal
text "[value] / [goal]"
key "keyup_K_SPACE" action [SetScreenVariable("value", value + 1), If(value >= goal, Return(True))]
timer duration:
action Return(value >= goal)
label start:
call screen qte
if _return:
"Succeeded!!!"
else:
"Failed!!!"
Regarding your code, I"m not sure what's wrong there, but you should be calling some of your screens there not showing it. Showing it will just make it proceed instantly to the next statement, which makes the game run the next codes immediately. If you're planning to do some infinite loop make sure first that you pause the execution of your code before looping again to avoid infinite loop error.
screen qte(duration=10.0, goal=50):
default value = 0
hbox:
bar value value range goal
text "[value] / [goal]"
key "keyup_K_SPACE" action [SetScreenVariable("value", value + 1), If(value >= goal, Return(True))]
timer duration:
action Return(value >= goal)
label start:
call screen qte
if _return:
"Succeeded!!!"
else:
"Failed!!!"
Regarding your code, I"m not sure what's wrong there, but you should be calling some of your screens there not showing it. Showing it will just make it proceed instantly to the next statement, which makes the game run the next codes immediately. If you're planning to do some infinite loop make sure first that you pause the execution of your code before looping again to avoid infinite loop error.
slr I tried calling some of the screens, but the results are less-than-ideal XD
Your code is a whole lot simpler though (tysm OwO)
Does the timer go out in the same speed as AnimatedValue when set in the same number of seconds?