• 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] Updating my custom script to v17

  • 465
    Posts
    8
    Years
    • Seen Jun 17, 2024
    So updating to v17 from v16, and i have a custom version of the pokegear, thats heavily different, however i cant load it in the same way as i did in v16 (same script) it was from within a button press in scene_map

    Code:
          if $Trainer.pokephone || $DEBUG
            pbLoadRpgxpScene(Scene_Pokephone.new)
          elsif $Trainer.pokegear
            pbLoadRpgxpScene(Scene_Pokegear.new)
          end
    Now this is actually fine, but when i close the menu i get a crash, now i use "$scene = Scene_Map.new" and that causes a crash with "playersprite". the script is unchanged from v16 its just exiting (tried changing to break but that causes another error.
    I'll leave the script below, but subject area is
    Code:
      def update_command
        if Input.trigger?(Input::B)
          if $game_variables[91]>=1
            $game_variables[91]-=1
            $scene = Scene_Pokephone.new
          else
            pbPlayCancelSE()
            $scene = Scene_Map.new <<< Here
            $game_switches[340] = false
              $game_switches[518] = false
              $game_variables[91]=0
            return
          end
        end

    and heres the full code. I also did try rewriting it to the new pokegear code but its met with failed attempts.

    Spoiler:
    For reference at what it looked like, this was it ingame. (i've changed the games ratio why it looks a larger than normal)
    [PokeCommunity.com] Updating my custom script to v17
     
    Now this is actually fine, but when i close the menu i get a crash, now i use "$scene = Scene_Map.new" and that causes a crash with "playersprite". the script is unchanged from v16 its just exiting (tried changing to break but that causes another error.

    Please screenshot and send the errors, just saying the error had "playersprite" isn't helpful. I'm not sure I see any obvious issues with your code, so without seeing the errors I'm really not sure where else to look.

    EDIT: Also, why not update to v18.1 instead of v17.2? It's good that you're updating at all, but I think even v17 will be outdated soon as more and more scripts drop support for it.
     
    Last edited:
    Please screenshot and send the errors, just saying the error had "playersprite" isn't helpful. I'm not sure I see any obvious issues with your code, so without seeing the errors I'm really not sure where else to look.

    EDIT: Also, why not update to v18.1 instead of v17.2? It's good that you're updating at all, but I think even v17 will be outdated soon as more and more scripts drop support for it.

    Im only updating to v17 so im not so far behind and while v18 is new some old scripts might not work/could need rewriting, but i plan to get their eventually.

    and sorry about that was kinda dumb not too.
    Code:
    [Pokémon Essentials version 17.2]
    Exception: NoMethodError
    Message: undefined method `playersprite' for nil:NilClass
    Sprite_DynamicShadows:210:in `initializeOldFL'
    Simple HUD:419:in `klein_animate_sp_initialize'
    KleinAnimatedTiles:162:in `old_initialize'
    Footprints:75:in `old_initialize_base'
    Secret Bases:789:in `initialize'
    Scene_Map:20:in `new'
    Scene_Map:20:in `createSpritesets'
    Scene_Map:19:in `each'
    Scene_Map:19:in `createSpritesets'
    PSystem_Utilities:1232:in `pbLoadRpgxpScene'

    seems to call any script that uses the same playersprite reference so.
    the oldFL reference is from the simple hud so i'll grab that also.
    Spoiler:
    Other ones like 'klein_animate_sp_initialize', 'old_initialize_base' are all different alias' for initialize so thats the target area.
     
    Last edited:
    Okay, I see like 4 different custom scripts in the error message, are you ABSOLUTELY sure that "Secret Bases", "Footprints", "KleinAnimatedTiles", and "Simple HUD" are all compatible with v17? I don't know much about the last two, but the first two have updated v17 versions:

    Footprints (by Marin): https://www.pokecommunity.com/showthread.php?p=10183546
    Secret Bases (Klein and Vendily): (broken link removed)

    I did some poking around with "pbLoadRpgxpScene" on v17, and I think it might have a bug? I don't know if it was present in v16 or not, but either way, there's a new way to call scenes, using the method "pbFadeOutIn". It will automatically take care of returning the scene back to the overworld when it's done. Replace:
    Code:
    if $Trainer.pokephone || $DEBUG
            pbLoadRpgxpScene(Scene_Pokephone.new)
          elsif $Trainer.pokegear
            pbLoadRpgxpScene(Scene_Pokegear.new)
          end
    with
    Code:
    if $Trainer.pokephone || $DEBUG
        pbFadeOutIn(99999) {
            scene = Scene_Pokephone.new
            scene.main
        }
    elsif $Trainer.pokegear
        pbFadeOutIn(99999) {
            scene = Scene_Pokephone.new
            scene.main
        }
    end
     
    Okay, I see like 4 different custom scripts in the error message, are you ABSOLUTELY sure that "Secret Bases", "Footprints", "KleinAnimatedTiles", and "Simple HUD" are all compatible with v17? I don't know much about the last two, but the first two have updated v17 versions:

    Footprints (by Marin): https://www.pokecommunity.com/showthread.php?p=10183546
    Secret Bases (Klein and Vendily): (broken link removed)

    I did some poking around with "pbLoadRpgxpScene" on v17, and I think it might have a bug? I don't know if it was present in v16 or not, but either way, there's a new way to call scenes, using the method "pbFadeOutIn". It will automatically take care of returning the scene back to the overworld when it's done. Replace:
    Code:
    if $Trainer.pokephone || $DEBUG
            pbLoadRpgxpScene(Scene_Pokephone.new)
          elsif $Trainer.pokegear
            pbLoadRpgxpScene(Scene_Pokegear.new)
          end
    with
    Code:
    if $Trainer.pokephone || $DEBUG
        pbFadeOutIn(99999) {
            scene = Scene_Pokephone.new
            scene.main
        }
    elsif $Trainer.pokegear
        pbFadeOutIn(99999) {
            scene = Scene_Pokephone.new
            scene.main
        }
    end

    Okay so that fix "works" it opens fine but immedietly closes out but leaves the graphics on screen. (as i can move around and not interact with the actual graphics)

    And could be an issue with them but all they seem to do is use the original initialize for the script itself.
    maybe using scene.main (while thats what it should do, it just does it wrong?)
     
    Hm, I think you'd need to modify your scenes a little to make it work with "pbFadeOutIn". But actually, Maruno just fixed "pbLoadRpgxpScene" in the latest version of Essentials (https://github.com/Maruno17/pokemon-essentials/commit/579a6cbe2a8b0a9d2068e4a1cd01ea32206a39f5), so you can switch your code back to using that. Basically, replace your entire "def pbLoadRpgxpScene" definition with the following:
    Code:
    def pbLoadRpgxpScene(scene)
      return if !$scene.is_a?(Scene_Map)
      oldscene = $scene
      $scene = scene
      Graphics.freeze
      oldscene.disposeSpritesets
      visibleObjects = pbHideVisibleObjects
      Graphics.transition(20)
      Graphics.freeze
      while $scene && !$scene.is_a?(Scene_Map)
        $scene.main
      end
      Graphics.transition(20)
      Graphics.freeze
      $scene = oldscene
      $scene.createSpritesets
      pbShowObjects(visibleObjects)
      Graphics.transition(20)
    end
    Then you can switch the code that calls your scenes with this (exactly what you had before):
    Code:
    if $Trainer.pokephone || $DEBUG
        pbLoadRpgxpScene(Scene_Pokephone.new)
    elsif $Trainer.pokegear
        pbLoadRpgxpScene(Scene_Pokegear.new)
    end
     
    Hm, I think you'd need to modify your scenes a little to make it work with "pbFadeOutIn". But actually, Maruno just fixed "pbLoadRpgxpScene" in the latest version of Essentials (https://github.com/Maruno17/pokemon-essentials/commit/579a6cbe2a8b0a9d2068e4a1cd01ea32206a39f5), so you can switch your code back to using that. Basically, replace your entire "def pbLoadRpgxpScene" definition with the following:
    Code:
    def pbLoadRpgxpScene(scene)
      return if !$scene.is_a?(Scene_Map)
      oldscene = $scene
      $scene = scene
      Graphics.freeze
      oldscene.disposeSpritesets
      visibleObjects = pbHideVisibleObjects
      Graphics.transition(20)
      Graphics.freeze
      while $scene && !$scene.is_a?(Scene_Map)
        $scene.main
      end
      Graphics.transition(20)
      Graphics.freeze
      $scene = oldscene
      $scene.createSpritesets
      pbShowObjects(visibleObjects)
      Graphics.transition(20)
    end
    Then you can switch the code that calls your scenes with this (exactly what you had before):
    Code:
    if $Trainer.pokephone || $DEBUG
        pbLoadRpgxpScene(Scene_Pokephone.new)
    elsif $Trainer.pokegear
        pbLoadRpgxpScene(Scene_Pokegear.new)
    end

    Perfect! thanks for the help even if it was more directing me to the fixes, was last thing really stopping me from a beta test
     
    Back
    Top