Two Coding Issues I'm Having [FIXED]

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.
Message
Author
User avatar
Buob
Newbie
Posts: 19
Joined: Sun Sep 09, 2012 3:47 am
Contact:

Two Coding Issues I'm Having [FIXED]

#1 Post by Buob » Sun Sep 09, 2012 4:09 am

Not sure if this is the right place to put this, but here goes;

I've been wanting to make some kind of game or write some kind of story, and I finally felt that visual novel was the way to go. After playing 999: 9 Hours, 9 Persons, 9 Doors and Kira Kira (and watching, then starting, Clannad), I felt like I needed to write a story that exceeded those works. This is partly where I get into my down fall.

The first thing I knew I wanted to include was a kid who was starting to write a will, but never gets to finish. I wanted to make it so that if you talked to him, later (when he was dead) you could say "Hey, it's the kid from earlier. Let's see what he was writing." If you didn't talk to him, that choice wouldn't be available. Scouring through the FAQs, the best I could get was the following:

Code: Select all

 "There's a boy sitting in front of me, frantically writing and erasing something on a piece of paper. I'm curious."
    menu: 
        "Find out what he's doing":
            $ choice == "will"
            jump will
        "Leave him alone, he probably doesn't want visitors":
    jump pass_1

    label will:
    h "Hey, what's the matter?"
    "The boy looks up at me."
    b "Nothing. Nothing's the matter."
    "This is obviously not the case, the boy is sweating and breathing heavily. On top of that, he's really pale and looks terrified. I decide to leave him alone."
    jump paper

    label pass_1:
    "But I figure he doesn't want anyone snooping, so I pass him by."

    label paper:
    "I look around the room. The boy who had wrote furiously on the piece of paper is now dead."
    menu:
        "Look at the paper": if choice == "will"
            "I look at the paper. One line occupies the page."
            "'To whom it may concern...'"
            "The rest is blank"
        "Don't look at the paper" if choice == "will"
            pass
I put it into Ren'py and got multiple errors. Being a novice, and since this won't appear until a little later, I put it into a .txt for easy viewing later.

The second problem I have is getting an existing character to move from the center of the window to the right side (and adding a new character on the left side) and back to the center without making everything move with them. Here's the current code for the two occurrences:

(Daichi is already at center)

Code: Select all

show daichi at right
    show Miyu at left
    with slideright

Code: Select all

 hide Miyu
    show daichi at center
    with slideleft
Again, I'm not certain if this is where it's supposed to go or not, but it would be great if someone could help me regardless.
Last edited by Buob on Sun Sep 09, 2012 11:00 pm, edited 1 time in total.

CaseyLoufek
Regular
Posts: 142
Joined: Sat May 28, 2011 1:15 am
Projects: Bliss Stage, Orbital Knights
Contact:

Re: Two Coding Issues I'm Having

#2 Post by CaseyLoufek » Sun Sep 09, 2012 5:07 am

Not sure without seeing the errors but you should indent after a label like this:

Code: Select all

   label will:
        h "Hey, what's the matter?"
        "The boy looks up at me."
        b "Nothing. Nothing's the matter."
        "This is obviously not the case, the boy is sweating and breathing heavily. On top of that, he's really pale and looks terrified. I decide to leave him alone."
        jump paper

User avatar
kankan
Regular
Posts: 80
Joined: Tue Mar 06, 2012 1:47 am
Contact:

Re: Two Coding Issues I'm Having

#3 Post by kankan » Sun Sep 09, 2012 5:17 am

You should probably post coding questions in the Questions and Announcements board, as more people will see it over there than in the Writing section. And CaseyLoufek is right, it's pretty hard to tell what's going on without the error messages. For the indentation, the general rule is that if there's a colon in the line, the stuff in the lines below will be indented too. Think of it like...the label is a springboard into the pool of codes that logically follow in that label. You can't jump off a springboard in the middle of the pool. That was a pretty terrible way of putting it, I'm sorry.

More on indenting, the labels should all touch the left side of the screen, rather than being indented under something else. There might be an error coming from your blank choice "Leave him alone..." if Ren'py complains about blank blocks (no indented code following a colon), and on your second menu, "Look at the paper" shouldn't have a colon after it.

As for the image statements, now it's the other way around. Those should all have the same indentation level. That may be what's wrong, but again, it's a little hard to tell without knowing the errors.

User avatar
Hiddlestoners
Regular
Posts: 126
Joined: Sun Jul 01, 2012 9:27 am
Completed: Thinking Of You [KN]
Projects: PERPLEXITY [Mystery VN], simplicity [KN,Fluff,GxB,BxG]
Contact:

Re: Two Coding Issues I'm Having

#4 Post by Hiddlestoners » Sun Sep 09, 2012 8:12 am

I agree with the others - you do need to make sure you indent everything properly or else it will become a cause for errors.
Moving onto your issues...
to get a choice to appear based on a variable becoming true earlier in the game, 1) make sure the variable is actually declared true:

Code: Select all

$ choice = True
2) you would put it in the menu like so:

Code: Select all

menu:
    "Find out what he's doing" if choice:
        jump will
    "Leave him alone, he probably doesn't want any visitors":
        jump pass_1
        
...

menu:
    "Look at the paper" if choice:
        ...
    "Don't look at the paper" if choice:
        ...
Onto the other issue, try:

Code: Select all

    show daichi at right
    show Miyu at left
    with moveinright
    
    ...
    
    hide Miyu
    show daichi at center
    with moveinright
ENOSHIMA BOWL!
Image

User avatar
Aedin
Regular
Posts: 137
Joined: Fri Sep 07, 2012 11:53 pm
Contact:

Re: Two Coding Issues I'm Having

#5 Post by Aedin » Sun Sep 09, 2012 10:14 am

The first problem is best dealt with like Hiddlestoners Toooom<3 said and using the True statements.

So, for the second issue, you want just the one image to move?

If you want just the latter image to move, then I think you have code it like this.
(Forgive me for not having the correct character names or transitions. I`m on my phone, and I can`t look back at what you said)

Code: Select all

show characterone at left
show charactertwo at right with moveinright
That will make just the latter character move. If you do it like below, then both characters move.

Code: Select all

show character one at left
show charactertwo at right
with moveinright
"There’s no shame in pleasure, Mr. Gray. You see, man just wants to be happy, but society wants him to be good. And when he’s good, man is rarely happy, and when he’s happy he is always good."

User avatar
Aedin
Regular
Posts: 137
Joined: Fri Sep 07, 2012 11:53 pm
Contact:

Re: Two Coding Issues I'm Having

#6 Post by Aedin » Sun Sep 09, 2012 4:53 pm

Aedin wrote:The first problem is best dealt with like Hiddlestoners Toooom<3 said and using the True statements.

So, for the second issue, you want just the one image to move?

If you want just the latter image to move, then I think you have code it like this.

Code: Select all

show daichi at left
show Miyu at right with moveinright
That will make just the latter character move. If you do it like below, then both characters move.

Code: Select all

show daichi at left
show Miyu at right
with moveinright
"There’s no shame in pleasure, Mr. Gray. You see, man just wants to be happy, but society wants him to be good. And when he’s good, man is rarely happy, and when he’s happy he is always good."

User avatar
Buob
Newbie
Posts: 19
Joined: Sun Sep 09, 2012 3:47 am
Contact:

Re: Two Coding Issues I'm Having

#7 Post by Buob » Sun Sep 09, 2012 7:02 pm

Wow, thanks everyone! As far as I can tell (since I'm still in the semi-beta stage) the "movein" is working.

As for the other problem, the choice issue, I put "$ choice = True" into the code, and am testing the entire scene separately. As of now, I have only one error: "End of line expected" for

Code: Select all

"Look at the paper": if choice == "will"

User avatar
Darkmoonfire
Regular
Posts: 103
Joined: Mon Apr 25, 2011 6:41 am
Completed: Christmas Project
Organization: Lunarescent Wings
Tumblr: darkmoonfire
Contact:

Re: Two Coding Issues I'm Having

#8 Post by Darkmoonfire » Sun Sep 09, 2012 7:25 pm

I'm think you have the colon in the wrong spot. I'm pretty sure that it's supposed to go at the very end like so...

Code: Select all

"Look at the paper" if choice == "will":

User avatar
Buob
Newbie
Posts: 19
Joined: Sun Sep 09, 2012 3:47 am
Contact:

Re: Two Coding Issues I'm Having

#9 Post by Buob » Sun Sep 09, 2012 8:10 pm

Darkmoonfire wrote:I'm think you have the colon in the wrong spot. I'm pretty sure that it's supposed to go at the very end like so...

Code: Select all

"Look at the paper" if choice == "will":
Nope, it says it expects a non-empty block.

User avatar
kankan
Regular
Posts: 80
Joined: Tue Mar 06, 2012 1:47 am
Contact:

Re: Two Coding Issues I'm Having

#10 Post by kankan » Sun Sep 09, 2012 8:45 pm

No, I'm pretty sure Darkmoonfire right. General rule of thumb is not to put colons in the middle of a statement. Not sure if technically this is how it works, but I'm guessing Ren'py is expecting some indented code directly after that colon, which "if choice == will" is not. Hence that error, rather than something directly telling you that the colon is in the wrong spot.

EDIT: Whoops, I missed that the errors changed. Colon still goes at the end of the line, but do you have any code following this?

User avatar
Buob
Newbie
Posts: 19
Joined: Sun Sep 09, 2012 3:47 am
Contact:

Re: Two Coding Issues I'm Having

#11 Post by Buob » Sun Sep 09, 2012 9:02 pm

kankan wrote:EDIT: Whoops, I missed that the errors changed. Colon still goes at the end of the line, but do you have any code following this?
This is the code in question:

Code: Select all

 menu:
        "Look at the paper"
            if choice == "will":
            "I look at the paper. One line occupies the page."
            "'To whom it may concern...'"
            "The rest is blank"
        "Don't look at the paper"
            if choice == "will":
            pass

User avatar
Victoria Jennings
Miko-Class Veteran
Posts: 715
Joined: Mon Jul 02, 2012 9:40 am
Contact:

Re: Two Coding Issues I'm Having

#12 Post by Victoria Jennings » Sun Sep 09, 2012 9:17 pm

I think you have to keep it on the same line.

Code: Select all

 menu:
        "Look at the paper" if choice == "will":
            "I look at the paper. One line occupies the page."
            "'To whom it may concern...'"
            "The rest is blank"
        "Don't look at the paper" if choice == "will":
            pass

User avatar
kankan
Regular
Posts: 80
Joined: Tue Mar 06, 2012 1:47 am
Contact:

Re: Two Coding Issues I'm Having

#13 Post by kankan » Sun Sep 09, 2012 9:22 pm

Buob wrote:
This is the code in question:

Code: Select all

 menu:
        "Look at the paper"
            if choice == "will":
            "I look at the paper. One line occupies the page."
            "'To whom it may concern...'"
            "The rest is blank"
        "Don't look at the paper"
            if choice == "will":
            pass
....Huuuu, I'm not sure quite how you want this to be written. At the moment, there should be errors coming from both of your "if choice == 'will':" statements because there's no indented code under them. So if you want it written like this, it should be

Code: Select all

menu:
    "Look at the paper"
        if choice == 'will':
            "I look at the paper. One line occupies the page."
            "'To whom it may concern...'"
            "The rest is blank"
    "Don't look at the paper"
        if choice == "will":
            pass
But I'm not sure that's how you want your code to work? This will show both choices for looking at the paper, but if you didn't choose "will" from somewhere earlier in the game, neither of these choices will do anything when clicked besides move to the next block. You probably want what Victoria Jennings wrote.

User avatar
Buob
Newbie
Posts: 19
Joined: Sun Sep 09, 2012 3:47 am
Contact:

Re: Two Coding Issues I'm Having

#14 Post by Buob » Sun Sep 09, 2012 9:32 pm

Victoria Jennings wrote:I think you have to keep it on the same line.

Code: Select all

 menu:
        "Look at the paper" if choice == "will":
            "I look at the paper. One line occupies the page."
            "'To whom it may concern...'"
            "The rest is blank"
        "Don't look at the paper" if choice == "will":
            pass

Yep, that made it work. Thank you, everyone!

EDIT: I tried it out, and when I choose the top option (the one that defines "choice") it errors out. "NameError: name "choice" not defined."

I did put "$ choice = True" in the init block at the top....

User avatar
kankan
Regular
Posts: 80
Joined: Tue Mar 06, 2012 1:47 am
Contact:

Re: Two Coding Issues I'm Having

#15 Post by kankan » Sun Sep 09, 2012 10:04 pm

Oh, see how when you define choice, it says

Code: Select all

$choice == "will"
? Make that one equal sign instead of two. Two signs means you're testing for equality, one sign means defining the variable.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Ocelot, _ticlock_