Hi
AON, i'd read your
You must be registered to see the links
and
You must be registered to see the links
threads and i'm worried.
[...]
I suddenly wonder if I should not replace my classes with simple lists ? hoping that I could save the lists, which are also objects!!!
You can use classes, you just need to declare them at the right moment, like explain in the How-To. Sometimes it will need a refactoring of your code, because "like this" it would conflict with the savability, but it's never impossible to use them.
Yes, because I code with a lot of files and no long code lines in one.
Here it's way more simple than it look at first :
The init process is split by level. Each init block (or init statement, like
define
among others), will be proceeded according to its level ; an
init -10
block will be proceeded before an
init -9
one.
And for each level, the block will be proceeded according to the alphabetical order of the file where they are. "[game/]myScript.rpy" will be proceeded before "[game/]script.rpy", that will be proceeded before "[game/]scripts/init.rpy".
Basically speaking, each time an init level is finished, Ren'py start a new init loop, processing the files in alphabetical order for the next init level.
Therefore, if you have :
myScript.rpy
Code:
init 10 python:
_log( "myScript - level 10" )
init python:
_log( "myScript - level 0" )
init -1 python:
_log( "myScript - level -1" )
scripts/init.rpy
Code:
init -1 python:
_log( "init - level -1" )
init python:
_log( "init - level 0" )
init 1 python:
_log( "init - level 1" )
scripts.rpy
Code:
init -100 python:
logFile = renpy.os.path.join( config.basedir, 'myLog.txt' )
def _log( msg ):
FH = open( logFile, "a" )
FH.write( msg + "\n" ) )
FH.close()
init -10 python:
_log( "script - level -10" )
init python:
_log( "script - level 0" )
init 1 python:
_log( "script - level 1" )
This will give you the following order :
- script - level -10
- myScript - level -1
- init - level -1
- myScript - level 0
- script - level 0
- init - level 0
- script - level 1
- init - level 1
- myScript - level 10
So, i tried to define my variables in labels
in the a.rpy file, i create a label loadFileA and in the b.rpy file, i create a label loadFileB
And in start label, i call loadFileB first, then loadFileA
and i obtain a poor "variable is being given a default a second time."
default
(like
define
) create its own context. Something like :
Code:
label whatever:
default myVar = "its value"
Have absolutely no meaning for Ren'py. It will still proceed the
default
statement at the start of the game and after each save loading.
I searched in renpy documentation and it seems you can control the order of declaration with different ways of init, but just for the "define" declarations.
Nothing for default variables.
Because, like I said yesterday,
default
is proceeded at a very particular time.
There's one and only one moment when the game start, like there's one and only one moment when a save file end being loaded.
What you need is to delay the moment you use the variable, not the moment you declare it.[/code]