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.
There's a small problem I'm trying to solve but I'm still a newbie on programming so can someone help me? I want the menu to be a part of the if statement as I made a menu choosing at the back, middle and front and each menu represents a character. The MC has to choose which seat she wants to take a sit and after MC chooses, she'll get special conversations exclusive to them, but the storyline (for now) is not branched yet so it'll be the same. The problem I'm having is that I don't know how to make the menu option special for the specific character.
$ back = True
c "H-huh? Y-you're sitting with me?"
"You nodded your head as you sat next to him."
"A small blush formed on his face, but it was gone as soon as it appeared."
$ middle = True
"You sat at the middle row of the class, waiting for the teacher to come."
"You scanned around the classroom as everyone was talking cheerifully with each other."
"There's an empty chair next to you, it was a window seat. You could not help but wonder about the new tranfer student."
g3 "Sorry but the only girl that he'll see is me and me only."
if back:
c "Jesus, these girls are crazy when it comes to new guys... I don't see anything special about him."
c "What do you think, [name]?"
menu:
"I guess he is pretty hot.":
jump hot
"I think you're cuter than him.":
jump cute
"I don't know, there's something about him I don't understand":
jump understand
After the Girl 3 spoke, it immediately went to the menu where it's supposed to be for Callisto (the character's name) only. I'll be waiting for your replies, ok guys? Please sacrifice some of your time to answer this newbie's question, thank you
You should show how you're setting the variables. Show the full code. You need a method of setting variables when you want them to set. Code is generally precederial, meaning it goes line by line.
$back = false
$middle = false
$back = true
if back
"hello"
This will set back to false, middle to false, then back to true. Meaning hello will display. Are you setting variables inside menu clicks? That would stop them from setting in order.
Fallen - Current project: Developing logic for RPG mechanics.
"Abel Hayes is feeling a little inhuman."
Fledgling Startup: Terra Byte Studios. https://www.tumblr.com/blog/terrabytestudio
$back = false
$middle = false
$front = false
character "Where do you want to sit?"
menu:
"back"
$back = true
"middle"
$middle = true
"front"
$front = true
if back
"You sit in the back."
if middle
"You sit in the middle"
if front
"You sit in the front"
Fallen - Current project: Developing logic for RPG mechanics.
"Abel Hayes is feeling a little inhuman."
Fledgling Startup: Terra Byte Studios. https://www.tumblr.com/blog/terrabytestudio
My problem lies more in = "How to insert a menu in an if fuction? And how to make that menu exclusive for that single if fuction and not the whole story/code?" and believe me, the whole code for this game is quite long so I'm not sure where to start copying and pasting the necessarry code for it. And I've done what you typed, Jeremy but what I need the most is to get this code:
menu:
"I guess he is pretty hot.":
jump hot
"I think you're cuter than him.":
jump cute
"I don't know, there's something about him I don't understand":
jump understand
For one character only without it appearing randomly during the "middle" and "front" option.
The reason I said to post more code was because your first post does not contain any logic at all. It's only code snippets that give us no idea as to how you're setting the variables. Anything could be happening. The best coders here-- a million times better than me-- are extremely intelligent, but they're not seers Best practice is to post all the logic. Everywhere that you're setting the variables is important for users to tell you what's going wrong.
label start:
$sally = False
"Is Sally here?"
if sally == False:
menu:
"yes.":
$sally = True
"no.":
$sally = False
if sally == True:
"Sally is here!"
else:
"Sally is not here"
return
Fallen - Current project: Developing logic for RPG mechanics.
"Abel Hayes is feeling a little inhuman."
Fledgling Startup: Terra Byte Studios. https://www.tumblr.com/blog/terrabytestudio
$ front = False
$ middle = False
$ back = False
c "where are you going to seat?"
menu:
"front":
jump back
"middle":
jump middle
"back":
jump back
label front:
$ front = True
a "You're sitting with me? Ok then."
jump story1
label middle:
$ middle = True
b "The seat next to me is free if you want."
jump story1
label back:
c "You can't see clearly at the back but it's the bext place to get a nap."
label story1
t "Alright then,there's gonna be a new student here. Meet D."
if front:
a "What do you think of him, [name]?"
menu:
"Not bad.":
jump notbad
"...":
jump ...
"I like you more.":
jump you
label notbad:
a "I guess he is not that bad."
jump story2
label ...:
a "Answer something."
jump story2
label you:
a "Well I'm glad not being replaced by him."
jump story2
if middle:
b "A new kid huh? What do you think of him?"
menu:
"I don't know.":
jump dontknow
"He looks weird.":
jump weird
"Meh...":
jump meh
label dontknow:
"Hard to say huh?"
jump story3
label weird:
"You think so?"
jump story3
label meh:
"That's kinda mean."
jump story3
if back
"Troublesome..."
menu:
"Indeed.":
jump indeed
"Seriously?":
jump seriously
"Not really.":
jump notreally
label indeed:
"I know right?"
jump story4
label seriously?:
"What? I'm lazy."
jump story4
labeln notreally:
"Still so troublesome."
jump story4
label story4:
t "Well, that's it, I guess. On to class."
I want to include the menus in the if fuction and that specific character only but I'm failing miserably to do so. Is there like another code of some sort?
if back
"Troublesome..."
menu:
"Indeed.":
jump indeed
"Seriously?":
jump seriously
"Not really.":
jump notreally
That whole section needs tabbed in. One heads up, python will not forgive miss-matched indentation.
When you start a label
label hello:
You tab in all lines that go in that block once, and then an if statement will be in that line, and then the code in the if statement will be tabbed. Don't forget the colon.
label here:
"some text tabbed in"
if cool:
"cool is set"
Indentation and colons are important
Fallen - Current project: Developing logic for RPG mechanics.
"Abel Hayes is feeling a little inhuman."
Fledgling Startup: Terra Byte Studios. https://www.tumblr.com/blog/terrabytestudio
You have been very helpful, Jeremy, and I only made that code because that's the much shorter version of it. But that is not answering my question. My question still lies with: how to "insert" the menu with the if fuction so for eg. if you choose an option, you'll get a special conversation with a character and that character only since the sitting arrangements are different. Each place will get a different character and different conversations but the main story line (the class itself) is the same. You'll also be able to choose an option as I plan to make several menu options for that specific character but the problem lies with the menu option itself.
The menu option will not be special to that character which is what I'm trying to solve. How to make those menus appear. In the game I'm developing, the menus for the characters still appear even though I choose a different option for the sitting arrangements and after that it flows along everything, regardless if I used the if fuction so maybe there's a code for that?
label start:
"this is the main path"
menu:
"optional path?":
$ optional_path = True
"carry on main path":
$ optional_path = False
if optional_path:
"this is the optional path"
"this is continuing the main path"
Alternate version below without using IF or python
label start:
"this is the main path"
menu:
"optional path?":
jump optional_path_01
"carry on main path":
jump main_path_01
label optional_path_01:
"this is the optional path"
label main_path_01:
"this is continuing the main path"
If we are what we repeatedly do, then good coding is not an act, but a habit
Yes you can include menus inside of an if statement. You can also include quite a lot of stuff in your menus as well. I took a look at your large chunk of code...and mostly I'm seeing lots of errors in your indentation (you can't have labels inside labels, for example). And if you have errors in your indentation, then your game is not going to work.
Other things I noted:
-initialize your variables using default
-you don't need those labels for the various small things the person says after you choose a menu option, you can just put that dialogue in the menu.
-when you have two+ options and the answer can't be more than one of those options, use if/elif/else. It is more efficient.
Anyway, here is my rewrite of your code. Tested and it works.
# Declare characters used by this game.
define a = Character('A', color="#c8ffc8")
define b = Character('B', color="#c8ffc8")
define c = Character('C', color="#c8ffc8")
define t = Character('T', color="#c8ffc8")
#Use default to declare your variable
default front = False
default middle = False
default back = False
default name = "Protag"
# The game starts here.
label start:
c "Where are you going to sit?"
menu:
"front":
$ front = True
a "You're sitting with me? Ok then."
"middle":
$ middle = True
b "The seat next to me is free if you want."
"back":
$ back = True
c "You can't see clearly at the back but it's the bext place to get a nap."
t "Alright then,there's gonna be a new student here. Meet D."
if front:
a "What do you think of him, [name]?"
menu:
"Not bad.":
a "I guess he is not that bad."
"...":
a "Answer something."
"I like you more.":
a "Well I'm glad not being replaced by him."
elif middle:
b "A new kid huh? What do you think of him?"
menu:
"I don't know.":
b "Hard to say huh?"
"He looks weird.":
b "You think so?"
"Meh...":
b "That's kinda mean."
else:
c "Troublesome..."
menu:
"Indeed.":
c "I know right?"
"Seriously?":
c "What? I'm lazy."
"Not really.":
c "Still so troublesome."
t "Well, that's it, I guess. On to class."
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?)
Ok, problem solved for that. But what about the continued story? Is it still the same and we use the if fuction or the elif, etc? For eg. after the teacher starts and explains a few things or so before asking a question to MC and the different characters commented on her answer? Cuz when I changed the code in the original (as the one above is a much shorter version of it) I still have the same problem. I'm still a newbie at this >.<
You just have to think through what you want to happen in an orderly and linear fashion and then figure out how you would order it.
You said: "after the teacher starts and explains a few things or so before asking a question to MC and the different characters commented on her answer?"
So let me show you how I break this down in my head:
1) The teacher starts and explains a few things. (So that will just be the normal talking).
2) The teacher asks a question to the MC and the MC has a choice of different answers. (That sounds like a menu).
3) The different characters sitting next to the MC will comment on her answer. (Since the responses are dependent on the answer, I see the responses being under each answer...and since the response will depend on which person is sitting next to her, that is were the if will be).
A sketch would look like:
Teacher Talks
Teacher asks a question
Menu of Answers:
----Answer 1:
--------if front:
------------Char A makes comment
--------elif middle:
------------Char B makes comment
--------else:
------------Char C makes comment
----Answer 2:
--------if front:
------------Char A makes comment
--------elif middle:
------------Char B makes comment
--------else:
------------Char C makes comment
----Answer 3:
--------if front:
------------Char A makes comment
--------elif middle:
------------Char B makes comment
--------else:
------------Char C makes comment
Teacher talks more
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?)