I have a minigame on my VN that uses imagemaps (Find the missing object) wherein if the player finds the required item in less than 50s, it jumps to label scene1. Else, jumps to label scene2.
I'm still working on the timer before I continue working on the image map.
I'm not really good at coding but I get this error that says Invalid Syntax. I'm not really good at coding
init:
python:
def countdown(st, at, length=0.0):
remaining = length - st
if remaining >= 50.0:
return Text("%.1f" % remaining, color="#fff", size=72), .1
jump scene1
elif remaining < 50.0:
return Text("%.1f" % remaining, color="#f00", size=72), .1
jump scene2
# Show a countdown for 10 seconds.
image countdown = DynamicDisplayable(countdown, length=60.0)
label start:
"this is a text"
show countdown at Position(xalign=.1, yalign=.1)
"test"
label scene1:
"here"
label scene2:
"test"
Ending based on time left?
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.
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.
- Empish
- Veteran
- Posts: 221
- Joined: Thu Jan 14, 2016 9:52 pm
- Projects: Efemural Hearts, It Ends With Graduation
- itch: empish
- Contact:
Re: Ending based on time left?
Okay, so I think you're running into naming issues here. You have both a python function and an image named countdown. Try changing one of those names to be different. The second thing is, when you call a function you need to provide all the required parameters for it. It looks like you're just providing the length?
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: Ending based on time left?
A version that works... might get you moving again
You could alternatively use a Timer or Bar with AnimatedValue which could automate the expired time action a bit
Code: Select all
init python:
def countdown(st, at, length=0.0):
global remaining
remaining = length - st
if remaining >= 10.0:
return Text("[remaining:.1f]", color="#fff", size=72), .1
if remaining <= 0.0:
renpy.hide_screen( 'test' )
renpy.jump( 'fail' )
return Text("[remaining:.1f]", color="#f00", size=72), .1
# default remaining = 15.0
screen test():
vbox:
add DynamicDisplayable(countdown, length=15.0)
textbutton "Found Me":
action [ Function(renpy.hide_screen, 'test'), Jump('found_me') ]
label start:
"this is a text"
call screen test
"test"
label found_me:
if remaining >= 10.0:
jump scene1
jump scene2
label scene1:
"success fast"
return
label scene2:
"success slow..."
return
label fail:
"Too slow"
return
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
Who is online
Users browsing this forum: Google [Bot], Majestic-12 [Bot]