Noob struggling with : after a choice

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.
Post Reply
Message
Author
baileykun
Newbie
Posts: 8
Joined: Wed Jan 16, 2019 2:33 am
Contact:

Noob struggling with : after a choice

#1 Post by baileykun »

So I started teaching myself how to use the program today, just a simple VN with an Affection system. Things were going smoothly until I made my first menu of choices. It worked until I added actions to one of the choices specifically. An error with the colon keep cropping up. I searched for at least an hour with no answer as to what I'm doing wrong. If someone could help me I'd be eternally grateful. I have attached the error message and a chunk of the code around the problem area.
Attachments
Capture line 40.PNG
Capture error 40.PNG

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3784
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Noob struggling with : after a choice

#2 Post by Imperf3kt »

On the line "I picked up the mug", remove the : from the end of the line.
Also, the menu and its content need to be indented once more.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

baileykun
Newbie
Posts: 8
Joined: Wed Jan 16, 2019 2:33 am
Contact:

Re: Noob struggling with : after a choice

#3 Post by baileykun »

Thanks, I implemented both changes I believe. I also fished out a line I realized wound up on the wrong side of the menu which was mucking things up. However, a new error cropped up and it seems to be rejecting my jump action now. I feel like I'm missing something critical here. (Falling asleep too, will have to check back in the morning.) So sorry for this mess. I'm not really sure where to look all this up and know the info is correct and up to date. I was teaching myself from a menagerie of resources and a bit of intuition.
Attachments
traceback.PNG
new line 40.PNG
New error.PNG

User avatar
Nagibator
Newbie
Posts: 16
Joined: Wed Jan 09, 2019 2:42 am
Contact:

Re: Noob struggling with : after a choice

#4 Post by Nagibator »

After implementing what Imperf3kt said, I'd recommend that you bring your jump statement back so that it is on the same indention as your "I picked up the mug..." quote. Also, bring "Let it cool." back as well (this includes it's body/contents). Also, I'm fairly positive you don't need a "$" before your jump statement.

Code: Select all

    "Meanwhile, the maid placed a nearby tray from a cart already waiting in the room onto the coffee table. "
    "It looks pretty hot, steam is wafting up from the mug. What should I do?"
    menu:
        "Drink the coffee.":
            "I picked up the mug and sipped slowly. The smooth yet complex flavor graced my tongue and warmed my chest."
            jump drink_coffee
        "Let it cool.":
            "I leave the steaming mug on the tray to cool down awhile."

label drink_coffee:
    "As I savored the ."
I don't particularly like fixing all of someone's code because they don't really learn much if they copy and paste it, but I'm fairly positive your mind is in the right place.

What I do recommend is to just focus on indentation. When I programmed in Java, my indentation didn't matter and my code could look as ugly as I wanted (no doubt it made things difficult later), but this is different.
Image

User avatar
mitoky
Veteran
Posts: 316
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, circus eterie
Contact:

Re: Noob struggling with : after a choice

#5 Post by mitoky »

Also here a bit explaining Nagibators code which might help:

Code: Select all

    "Meanwhile, the maid placed a nearby tray from a cart already waiting in the room onto the coffee table. "
    "It looks pretty hot, steam is wafting up from the mug. What should I do?"
    menu:
        "Drink the coffee.":
            "I picked up the mug and sipped slowly. The smooth yet complex flavor graced my tongue and warmed my chest."
            jump drink_coffee
        "Let it cool.":
            "I leave the steaming mug on the tray to cool down awhile."

label drink_coffee:
    "As I savored the ."
The "Meanwhile, the maid (...)" part, is part of a label. imagine the label like a folder and each content of that label is "inside" that folder, hence 4 spaces.
The menu is in the same "folder" , hence its too intended, and the choices are part of the menu, hence the menu itself is too a folder and has the : and the content has +4 more spaces.
Since the choices do something as well they can too be considered a folder, hence they too have the : and everything "inside" that has +4 more spaces.

jump is not part of the line "I picked up the mug(...)" but of the choice "Drink the coffe" hence its on the same line. And jump doenst needs $, $ is used to change variables.


Since the next label, "drink_coffee" is not part of the previous label nor anything, its on a completly new line on its own at the start.

I hope this helped a bit!

baileykun
Newbie
Posts: 8
Joined: Wed Jan 16, 2019 2:33 am
Contact:

Re: Noob struggling with : after a choice

#6 Post by baileykun »

Thanks so much to both of you. I fiddled around with it all a bit and I was able to fix it all. I think I understand how it works better now, especially my indentation. I even added the affection points to the menu without breaking anything. I don't know why all the code examples I saw were covered in colons and $jump. Oh well.

Post Reply

Who is online

Users browsing this forum: Google [Bot], myself600