[solved]The order of initialization causes a name error, why?

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
Chekhov
Regular
Posts: 113
Joined: Tue Jun 26, 2018 9:19 am
Projects: Pluton
Contact:

[solved]The order of initialization causes a name error, why?

#1 Post by Chekhov »

This is a problem that's puzzling me. I can't figure out to fix this error.

This is an error that pops up before the game fully initialises and it seems to do so out of order.

The relevant files are script.rpy, storylines_init.rpy and out_the_door.rpy

The relevant code from script.rpy :

Code: Select all

call storylines_init
jump day_loop
The relevant code from storylines_init.rpy :

Code: Select all

label storylines_init:

init python:

    class Storyline(object):

        def __init__(self, name="Storyline_name_undefined"):
            self.name = name
            
    Leavehouse = Storyline("Leavehouse")

    Leavehouse.tries = 0
    Leavehouse.today = 0
And finally the code from out_the_door.rpy :

Code: Select all

label out_the_door:

init python:
    #test insert place
    iloop = Leavehouse.tries
Of course there is other stuff in day_loop that eventually arrives at out_the_door. I think I'm flabbergasted at the order in which the initialization occurs. I would have expected it to follow the logical order that program follows once running, including following the jumps and calls.

When I add the code of storylines_init at #test insert place it starts up fine. What am I missing here?

User avatar
Chekhov
Regular
Posts: 113
Joined: Tue Jun 26, 2018 9:19 am
Projects: Pluton
Contact:

Re: [solved]The order of initialization causes a name error, why?

#2 Post by Chekhov »

ahh nevermind. I figured it out. I shouldn't be using...

Code: Select all

init python:
...for something that isn't initilization

Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot], Majestic-12 [Bot], Semrush [Bot]