Ren'Py Quest (Tasks) System recomendation

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,701
Just to comment...

I changed this:
Code:
def reset( self ):
            self._actualStage = 0
            self._stages = []                    ### Line added
            self._iterationsLeft = []
            for s in self._stages:
                self._iterationsLeft.append( s[1] )
To reset the text in "stages" too.


The system works perfectly... but I'm having problems with the after_load because it adds extra "stages" to my existing ones, that's why I've reviewed the "reset", so at least I can start from scratch and add the necessary quests at each stage and adjust it to its correct progress.

(Starting the game from the beginning everything is fine, the problem is that if the after_load is not correct, when the game is saved and reloaded, everything is broken)
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,857
15,989
but I'm having problems with the after_load because it adds extra "stages" to my existing ones,
Do you test the number of stage before adding new ones in after_load ? Like you just add stages, the actual number of stages give you the version of the game used to generate the save file. And if in one version you don't add stage to a given quest, it still works, since the number of stages don't change.
Normally the part in after_load should looks like this :
Code:
label start:
    $ questA = Quest( "charA" )
    $ questA.addStage( "stage 1" )
    $ questA.addStage( "stage 2" )

label after_load:
    if questA.numberStages() == 2:
    # It's the update for people using a save of the 0.1 version of the game
        $ questA.addStage( "stage 3" )
        $ questA.addStage( "stage 4" )
        $ questA.addStage( "stage 5" )

    if questA.numberStages() == 5:
    # It's the update for people using a save of the 0.2 version of the game
        $ questA.addStage( "stage 6" )
   
    if questA.numberStages() == 6:
    # It's the update for people using a save of the 0.3 version of the game
        $ questA.addStage( "stage 7" )
Done this way, it shouldn't add unwanted stages. Either there's 2 stages, and it's a save coming from the version 0.1 of the game, or there's more, and so the stages 3, 4 and 5 already exist and don't need to be added.
Then, it will test if the number of stage is 5. If it's the case, it will add the stage 6, whatever the player effectively used a save from the version 0.2 of the game, or if the stages 3, 4 and 5 were added a second ago because it's a save from the version 0.1.
And so on, update of the game by update of the game. This way all possibilities are covered, and you shouldn't have unwanted stages.

But I can have missed something. It's midnight here, and it's still 30°C, so I don't guaranty that my brain is working correctly.
 
  • Like
Reactions: Porcus Dev

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,701
Do you test the number of stage before adding new ones in after_load ? Like you just add stages, the actual number of stages give you the version of the game used to generate the save file. And if in one version you don't add stage to a given quest, it still works, since the number of stages don't change.
Normally the part in after_load should looks like this :
Code:
label start:
    $ questA = Quest( "charA" )
    $ questA.addStage( "stage 1" )
    $ questA.addStage( "stage 2" )

label after_load:
    if questA.numberStages() == 2:
    # It's the update for people using a save of the 0.1 version of the game
        $ questA.addStage( "stage 3" )
        $ questA.addStage( "stage 4" )
        $ questA.addStage( "stage 5" )

    if questA.numberStages() == 5:
    # It's the update for people using a save of the 0.2 version of the game
        $ questA.addStage( "stage 6" )
  
    if questA.numberStages() == 6:
    # It's the update for people using a save of the 0.3 version of the game
        $ questA.addStage( "stage 7" )
Done this way, it shouldn't add unwanted stages. Either there's 2 stages, and it's a save coming from the version 0.1 of the game, or there's more, and so the stages 3, 4 and 5 already exist and don't need to be added.
Then, it will test if the number of stage is 5. If it's the case, it will add the stage 6, whatever the player effectively used a save from the version 0.2 of the game, or if the stages 3, 4 and 5 were added a second ago because it's a save from the version 0.1.
And so on, update of the game by update of the game. This way all possibilities are covered, and you shouldn't have unwanted stages.
Uhmm... I think I tried it this way at first and I had some problem, surely my fault for not fully understanding the full code... to see that it didn't work, change "numberStages" by "actualQuest" and this was my big mistake, now I see it :eek:

In the end, as that part of the "after_load" is executed only once, what I have done is to do a "reset" and then add "Stages" according to other variables of the game, placing each mission in the part of the game where it corresponds... It was probably longer and more complicated to do, but it worked! :D And along the way I've learned better how the code works :p

For the next update, as the "Stages" will be perfectly defined, it will be easier to create the new part in the "after_load"... although, now that I think about it, it wouldn't be necessary, because for the new "Stages", I can add directly to the new code of the game (after all, they go after the present ones)

But I can have missed something. It's midnight here, and it's still 30°C, so I don't guaranty that my brain is working correctly.
LOL, It's unbearably hot in here too, you can't work well like that... you can't! :ROFLMAO:
 
  • Like
Reactions: anne O'nymous

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,857
15,989
LOL, It's unbearably hot in here too, you can't work well like that... you can't! :ROFLMAO:
It's more or less what my boss (and friend) said when I joined him for an one hour long "do nothing, don't talk, don't move" pause today. Just looking at the youngest continue to code was exhausting :D
 
  • Haha
Reactions: Porcus Dev