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.
-
Smaymay
- Regular
- Posts: 70
- Joined: Fri Jul 01, 2016 11:35 am
- Completed: Vicboys demo
- Tumblr: esmmeh
- Deviantart: Smaymay
- Location: The Netherlands
-
Contact:
#1
Post
by Smaymay » Fri Mar 17, 2017 1:30 pm
Just like the title says. XD
I have this point system. Nothing fancy. Just something like this:
Code: Select all
menu:
"I hate you.":
$ JohnPoints -= 1
$ renpy.fix_rollback()
jump john_1
"I love you.":
$ JohnPoints += 1
$ renpy.fix_rollback()
jump john_2
But now it's possible to have -1 JohnPoints. I'd like to prevent this variable from going below 0.
I tried to achieve this with an If statement.
Code: Select all
if JohnPoints < 0:
$ JohnPoints = 0
It didn't work though.
Does anyone have any advice?
~ thanks ~
Last edited by
Smaymay on Fri Mar 17, 2017 2:40 pm, edited 3 times in total.
-
trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
-
Contact:
#2
Post
by trooper6 » Fri Mar 17, 2017 1:32 pm
The code you quoted was this:
Code: Select all
if MinotonPoints < 0:
$ JohnPoints == 0
I think you mean:
Code: Select all
if JohnPoints < 0:
$ JohnPoints = 0
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe:
http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
-
Smaymay
- Regular
- Posts: 70
- Joined: Fri Jul 01, 2016 11:35 am
- Completed: Vicboys demo
- Tumblr: esmmeh
- Deviantart: Smaymay
- Location: The Netherlands
-
Contact:
#3
Post
by Smaymay » Fri Mar 17, 2017 1:51 pm
@trooper6
Yes thanks for the heads up. I changed the name before posting it on this forum because Minoton is a rather strange name.
I'll edit my post.
-
xavimat
- Eileen-Class Veteran
- Posts: 1458
- Joined: Sat Feb 25, 2012 8:45 pm
- Completed: Yeshua, Jesus Life, Cops&Robbers
- Projects: Fear&Love, unknown
- Organization: Pilgrim Creations
- Github: xavi-mat
- itch: pilgrimcreations
- Location: Spain
-
Contact:
#4
Post
by xavimat » Fri Mar 17, 2017 2:15 pm
Your code with "if" should work, but you need to call it every time.
Instead of:
$ points -= 1
# some code to check
I suggest using the max() funtion every time you want to take points from the variable:
$ points = max(0, points-1)
If you need a maximum range you can use min()
$ points = min(100, points+1) # assuming the maximum is 100
-
Smaymay
- Regular
- Posts: 70
- Joined: Fri Jul 01, 2016 11:35 am
- Completed: Vicboys demo
- Tumblr: esmmeh
- Deviantart: Smaymay
- Location: The Netherlands
-
Contact:
#5
Post
by Smaymay » Fri Mar 17, 2017 2:39 pm
@xavimat
It worked like a charm. Thank you!
