Event stops working when added "from" clause

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
tcassat
Regular
Posts: 33
Joined: Tue Oct 03, 2017 7:32 pm
Contact:

Event stops working when added "from" clause

#1 Post by tcassat »

Hello!

I had this problem and I couldn't understand the cause. If anyone could help me to clarify this, I would be grateful.

I created an event like this (simplified):

Code: Select all

label computer:
    "The computer is on."
    label .choices:
        "Choose an option:
        
        menu:
            "Option A":
                call option_a
                jump .choices
               
             "Option B":
                 "same thing here..."
                
            "Turn off computer":
                jump map_home
        
label option_a:
    menu:
        "option 1":
            "something here..."
        "go back":
            return        
        
        
        
I rewrote this now, there may be a mistake, but when I did in my game, it worked perfectly. When you chose "Option A", for example, Renpy called the label "option_a". When the player chose "go back" (inside label option_a), he returned to the previous label, and the next line was "jump .choices", and working as expected.

However, when I did the distribuition package, Renpy added the "from" clause (_call_option_a), and the event broke. It looked like this:

Code: Select all

label computer:
    "The computer is on."
    label .choices:
        "Choose an option:
        
        menu:
            "Option A":
                call option_a from _call_option_a
                jump .choices
               
             "Option B":
                 "same thing here..."
                
            "Turn off computer":
                jump map_home
        
label option_a:
    menu:
        "option 1":
            "something here..."
        "go back":
            return        
        
        
        

And the error: could not find label '_call_option_a.choices'

What I understood was that he was looking for the local label in the wrong place. The local label ".choices" was inside the label "computer" and not the label "option_a".

What puzzled me was that the event was working before Renpy added the "from" clause, that is, before creating the distribution package. Are there any details that I did not realize? Do I really need to add this "from" clause (since the event worked without it)?

Thank you.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Event stops working when added "from" clause

#2 Post by trooper6 »

You know that menus can have labels right? So you could just do:

Code: Select all

label computer:
    "The computer is on."
    menu comp_choices:
        "Choose an option:"
        "Option A":
            call option_a
            jump comp_choices
               
         "Option B":
             "same thing here..."
                
        "Turn off computer":
            jump map_home
        
label option_a:
    menu:
        "option 1":
            "something here..."
        "go back":
            return       
The code you've witten is going to have problems though because it isn't complete in a way that is going to mess with the flow...so, I'd recommend fixing that before you move forward...if you haven't already. For example. If the player picks option B, because it just has text, the game will go to the next line...which will be label option_a...which I assume you don't actually want to happen. So make sure you actually put something in the Option B menu option. Also for the label option_a...go back returns which is good...but Option 1 doesn't...which isn't good...because you do need to return at some point to your earlier menu.
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?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], piinkpuddiin