Hi All!
So I've lately been trying to work on a practice visual novel in RenPy, and I'm trying to get my point system to work. Here's what I've written:
init:
#Points system
$ points = 0
$ points_max = 100
if points >= 70:
jump best_ending
elif points >= 50:
jump good_ending
elif points >= 30:
jump bad_ending
else:
jump worst_ending
# Declare characters used by this game.
$ x = Character(' ', color="#c8ffc8")
$ e = Character ('Ella', color="#c8ffc8")
#The game starts here.
label start:
e "AHHH!"
____________________________
It all seems fine and dandy and will bring up the game menu, but as soon as I click 'Start game' an error window pops up saying that "Sayer e is not defined"
You can see clearly above that I have in fact defined 'e' as the sayer (speaker) Ella.
Now when I remove my point system and launch it, without touching where I define Ella as a speaker, everything goes smoothly. but of course, I don't have my point system anymore.
Can anyone help with this problem?
Help? Trying to use Else, If and Elif Statements in Renpy
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.
- Marionette
- Regular
- Posts: 128
- Joined: Thu Apr 21, 2011 12:04 pm
- Completed: https://marionette.itch.io/
- Projects: Get Meowt of Here
- Deviantart: rexx9224
- itch: marionette
- Location: Ireland
- Discord: Marionette#2995
- Contact:
Re: Help? Trying to use Else, If and Elif Statements in Renp
$ x = Character(' ', color="#c8ffc8")
$ e = Character ('Ella', color="#c8ffc8")
to
define x = Character(' ', color="#c8ffc8")
define e = Character ('Ella', color="#c8ffc8")
and see if that helps.
Edit:
Think i figured out the issue. You shouldn't have your if statement in the init block. The game is basically jumping to the ending labels before it has set up the characters, right as the game starts, as the jumps are in the init block.
Put your if ending check in a separate label and then call into it when your game gets to the point of choosing an ending.
Re: Help? Trying to use Else, If and Elif Statements in Renp
That seemed to have worked.
Thank you very much ^_^ I have been crawling into a ball of frustration over this for days.
I truly appreciate it.
Thank you very much ^_^ I have been crawling into a ball of frustration over this for days.
I truly appreciate it.
Re: Help? Trying to use Else, If and Elif Statements in Renp
Were you intending that by putting the if statements in the init that it would get checked constantly and automatically trigger if the conditions were met? If so, that wouldn't do that, and the actual way to do that is kind of complicated. It'd probably be best to put that in its own label, like:
oh, and put code in [-code-] blocks, minus the -'s, to retain indents.
Code: Select all
label CheckEnding:
if points >= 70:
jump best_ending
elif points >= 50:
jump good_ending
elif points >= 30:
jump bad_ending
else:
jump worst_ending
# and then when you want to reach the ending, just. . .
jump CheckEnding