• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] I do not know why, but I cant manage to backup my Team

  • 80
    Posts
    6
    Years
    • Seen Nov 5, 2023
    So... I have added two simple scripts to my game

    Code:
    def pbBackupTeam
      $game_variables[40]=$Trainer.party
    end
    
    def pbReturnParty
      $Trainer.party=$game_variables[40]
    end

    And the pbBackupTeam parts works,
    My idea is that after I backup the team I set the Team level to 50 for a trainer battle and after that the Levels return to whatever they were. This is why I run after pbBackupTeam a script that sets the levels of the entire team to 50

    for poke in $Trainer.party
    poke.level = 50
    poke.calcStats
    poke.heal
    end

    But here comes the problem, when I use pbReturnParty afterwards. My Team stays the same
    Please help

    Why does
    def pbReturnParty
    $Trainer.party=$game_variables[40]
    end
    not work?

    Thanks in advance!
    -TritraSerpifeu
     
    The reason your team stays the same is not a problem in your return function, it's actually a problem in your backup function. When you do "$game_variables[40] = $Trainer.party", all you're doing is setting that variable equal to the trainer's party. In other words, you are not COPYING the Pokemon over, so if you make any changes to the trainer's party, those changes are reflected in variable 40 as well. You need to copy each Pokemon individually in your backup function like this:
    Code:
    def pbBackupTeam
        $game_variables[40] = []
        for poke in $Trainer.party
            $game_variables[40].push(Marshal.load(Marshal.dump(pokemon)))
        end
    end
    Again, your restore method is fine, you just need to replace your backup method with the one above.
     
    I tried your script, but I only got a error:

    ---------------------------
    Pokémon Laughing Lapis Demo
    ---------------------------
    [Pokémon Essentials version 17.2]

    [Pokétch v1.1]

    Exception: RuntimeError

    Message: Script error within event 7 (coords 36,71), map 165 (Battle frontier):

    Exception: NameError

    Message: Rental house:65:in `pbBackupTeam'undefined local variable or method `pokemon' for #<Interpreter:0x10f06ba8>

    ***Full script:

    pbBackupTeam


    Interpreter:243:in `pbExecuteScript'

    Rental house:64:in `each'

    Rental house:64:in `pbBackupTeam'

    (eval):1:in `pbExecuteScript'

    Interpreter:1606:in `eval'

    Interpreter:243:in `pbExecuteScript'

    Interpreter:1606:in `command_355'

    Interpreter:494:in `execute_command'

    Interpreter:193:in `update'

    Interpreter:106:in `loop'



    Interpreter:276:in `pbExecuteScript'

    Interpreter:1606:in `command_355'

    Interpreter:494:in `execute_command'

    Interpreter:193:in `update'

    Interpreter:106:in `loop'

    Interpreter:198:in `update'

    Scene_Map:163:in `update'

    Scene_Map:161:in `loop'

    Scene_Map:170:in `update'

    Scene_Map:234:in `main'



    This exception was logged in

    C:\Users\User\Saved Games\Pokémon Laughing Lapis Demo\errorlog.txt.

    Press Ctrl+C to copy this message to the clipboard.
    ---------------------------
    OK
    ---------------------------

    I am not sure why, because $game_variables[40] exists...
     
    The reason your team stays the same is not a problem in your return function, it's actually a problem in your backup function. When you do "$game_variables[40] = $Trainer.party", all you're doing is setting that variable equal to the trainer's party. In other words, you are not COPYING the Pokemon over, so if you make any changes to the trainer's party, those changes are reflected in variable 40 as well. You need to copy each Pokemon individually in your backup function like this:
    Code:
    def pbBackupTeam
        $game_variables[40] = []
        for poke in $Trainer.party
            $game_variables[40].push(Marshal.load(Marshal.dump(pokemon)))
        end
    end
    Again, your restore method is fine, you just need to replace your backup method with the one above.

    Code:
    ---------------------------
    Pokémon Laughing Lapis Demo
    ---------------------------
    [Pokémon Essentials version 17.2]
    
    [Pokétch v1.1]
    
    Exception: RuntimeError
    
    Message: Script error within event 7 (coords 36,71), map 165 (Battle frontier):
    
    Exception: NameError
    
    Message: Rental house:65:in `pbBackupTeam'undefined local variable or method `pokemon' for #<Interpreter:0x10fddfc0>
    
    ***Full script:
    
    pbBackupTeam
    
    
    Interpreter:243:in `pbExecuteScript'
    
    Rental house:64:in `each'
    
    Rental house:64:in `pbBackupTeam'
    
    (eval):1:in `pbExecuteScript'
    
    Interpreter:1606:in `eval'
    
    Interpreter:243:in `pbExecuteScript'
    
    Interpreter:1606:in `command_355'
    
    Interpreter:494:in `execute_command'
    
    Interpreter:193:in `update'
    
    Interpreter:106:in `loop'
    
    
    
    Interpreter:276:in `pbExecuteScript'
    
    Interpreter:1606:in `command_355'
    
    Interpreter:494:in `execute_command'
    
    Interpreter:193:in `update'
    
    Interpreter:106:in `loop'
    
    Interpreter:198:in `update'
    
    Scene_Map:163:in `update'
    
    Scene_Map:161:in `loop'
    
    Scene_Map:170:in `update'
    
    Scene_Map:234:in `main'

    I tired it and I got this error, I do not know why... though
     
    Back
    Top