Page 1 of 1

Calling the label on all screens

Posted: Wed Feb 17, 2021 12:23 pm
by oldhiccup
I have a variable label, basically these variables control some aspects within my game.

I have a loop that performs an event check, and before the loop I execute the calling of these variables, however during the game, I need to create new variables and find that I have to restart the whole game so that my variable is defined, or call the label at the beginning of my new script file.


To avoid having to call this, I put my variable variable inside my loop but even so it doesn't work, how do I make the variable available to me at any time during development, without having to call it again?

Code: Select all

label variables:
    $ varA = 0
    $ varB = 1
    return

label loop:
    while runing:
        call variables
        call event
    return

Re: Calling the label on all screens

Posted: Wed Feb 17, 2021 1:08 pm
by gas
oldhiccup wrote: Wed Feb 17, 2021 12:23 pm I have a variable label, basically these variables control some aspects within my game.

I have a loop that performs an event check, and before the loop I execute the calling of these variables, however during the game, I need to create new variables and find that I have to restart the whole game so that my variable is defined, or call the label at the beginning of my new script file.


To avoid having to call this, I put my variable variable inside my loop but even so it doesn't work, how do I make the variable available to me at any time during development, without having to call it again?

Code: Select all

label variables:
    $ varA = 0
    $ varB = 1
    return

label loop:
    while runing:
        call variables
        call event
    return
You're a bit confused about coding in renpy/python.
Obviously if you add a new variable, the game will know of it only at re-running of it. Is not retroactive (and believe me: there's no coding that work fine retroactively).

ANYWAY, and read carefully: if you save the game with a code so made, the whole thing implode.
Variables that should be pickled, as ones that determine a flux control, should be declared as default.
Read the docs where it does explain default variable declarement (the one you're not using and you should), that will hint you why you had to call the variables label at the start of the game (and maybe try to understand the INIT phase).

Re: Calling the label on all screens

Posted: Wed Feb 17, 2021 11:26 pm
by zmook
The code you provided looks like it should work. There are lots of reasons a variable might be out of scope when you try to use it, though, and I can't guess from this which problem you might have. Can you post more of your real code that has the problem?