Indenting problem?

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
User avatar
warmsundae
Regular
Posts: 61
Joined: Tue Feb 24, 2015 9:51 pm
Skype: electriclan
Soundcloud: lanterny
Location: korea
Contact:

Indenting problem?

#1 Post by warmsundae » Wed Mar 25, 2015 8:34 am

I may be making the code too complicated for myself.

But the problem is this:

Code: Select all

File "game/script.rpy", line 66: expected menuitem
    if wood >= 10:
    ^
this is the code that I think is relevant:
(if I need anything else, I'll be sure to add it in.)

Code: Select all

label action_menu:
    menu:
        "Gather wood.":
            $ wood += 2
            a "You gather 2 wood."
            if people >= 0:
                $ wood += 2
                a "Your people gather 2 more wood."
            elif people >= 5:
                $ wood += 6
                a "Your people gather 6 more wood."
            elif people >= 10:
                $ wood += 10
                a "Your people gather 10 more wood."
            elif people >= 15:
                $ wood += 20
                a "Your people gather 20 more wood."
            a "You now have [wood] wood."
            jump action_menu
        
        if wood >= 10:
            "Build a hut.":
                a "You spend 10 wood and build a hut."
                $ hut += 1
                $ wood -= 10
                jump action_menu
        else:
            pass
        
        if wood >= 25:
            if not workshop:
                "Build a workshop.":
                    $ wood -= 25
                    $ workshop = True
                    jump action_menu
            else:
                pass
        else:
            pass
            
        if wood >= 50:
            if not trading_post:
                "Build a trading post.":
                    $ wood -= 50
                    $ workshop 
                    jump action_menu
            else:
                pass
        else: 
            pass
So far it's just been indenting errors, but I can't seem to figure this one out. Maybe I'm just missing something simple?

User avatar
Queex
Regular
Posts: 46
Joined: Sat Mar 14, 2015 9:47 am
Contact:

Re: Indenting problem?

#2 Post by Queex » Wed Mar 25, 2015 9:01 am

The menu choices must begin with strings, showing what the choice is. If you want a condition on when the option appears, you put the if statement afterwards:

Code: Select all

    "build a hut" if wood >=10:
        ...
It gets called an indentation error because ren'py's best-guess as to what you were trying to do is that the menu section had ended and you intended to be back in the label block.

User avatar
warmsundae
Regular
Posts: 61
Joined: Tue Feb 24, 2015 9:51 pm
Skype: electriclan
Soundcloud: lanterny
Location: korea
Contact:

Re: Indenting problem?

#3 Post by warmsundae » Wed Mar 25, 2015 9:30 am

oh! I understand now. I never knew that rule.
Thanks so much!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Ocelot, zyric