• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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.

Autosave

#Not Important

All hail the wishmaker
910
Posts
4
Years
  • For me, it was a pain having to save my game each time I had to shut the console down...

    So, I made this script:
    Code:
    #------------------------------------------------------------------------------#
    #==============================================================================#
    #                                                                              #
    #                                Autosave Script                               #
    #                               By #Not Important                              #
    #                                                                              #
    #==============================================================================#
    #------------------------------------------------------------------------------#
    #==============================================================================#
    #                                                                              #
    #It is a very simple script, if the player moves, the game is saved            #
    #                                                                              #
    #==============================================================================#
    #------------------------------------------------------------------------------#
    
    class Game_Player < Game_Character #It is handled as a Game_Player < Game_Character
      def move_down(turn_enabled = true)#Extension
        turn_down if turn_enabled
        if passable?(@x, @y, 2)
          return if pbLedge(0,1)
          return if pbEndSurf(0,1)
          turn_down
          @y += 1
          $PokemonTemp.dependentEvents.pbMoveDependentEvents
          increase_steps
        else
          if !check_event_trigger_touch(@x, @y+1)
            if !@bump_se || @bump_se<=0
              pbSEPlay("Player bump"); @bump_se = 10
            end
          end
        end
        pbSave       #Saves the game if the player has moved down
      end
    
      def move_left(turn_enabled = true)
        turn_left if turn_enabled
        if passable?(@x, @y, 4)
          return if pbLedge(-1,0)
          return if pbEndSurf(-1,0)
          turn_left
          @x -= 1
          $PokemonTemp.dependentEvents.pbMoveDependentEvents
          increase_steps
        else
          if !check_event_trigger_touch(@x-1, @y)
            if !@bump_se || @bump_se<=0
              pbSEPlay("Player bump"); @bump_se = 10
            end
          end
        end
        pbSave       #Saves the game if the player has moved left
      end
    
      def move_right(turn_enabled = true)
        turn_right if turn_enabled
        if passable?(@x, @y, 6)
          return if pbLedge(1,0)
          return if pbEndSurf(1,0)
          turn_right
          @x += 1
          $PokemonTemp.dependentEvents.pbMoveDependentEvents
          increase_steps
        else
          if !check_event_trigger_touch(@x+1, @y)
            if !@bump_se || @bump_se<=0
              pbSEPlay("Player bump"); @bump_se = 10
            end
          end
        end
        pbSave       #Saves the game if the player has moved right
      end
    
      def move_up(turn_enabled = true)
        turn_up if turn_enabled
        if passable?(@x, @y, 8)
          return if pbLedge(0,-1)
          return if pbEndSurf(0,-1)
          turn_up
          @y -= 1
          $PokemonTemp.dependentEvents.pbMoveDependentEvents
          increase_steps
        else
          if !check_event_trigger_touch(@x, @y-1)
            if !@bump_se || @bump_se<=0
              pbSEPlay("Player bump"); @bump_se = 10
            end
          end
        end
        pbSave       #Saves the game if the player has moved up
      end
    end
    Tell me if you have any errors!
     
    971
    Posts
    7
    Years
    • Age 21
    • Seen Nov 28, 2022
    This also moves when you don't actually move (i.e. bump into a wall). That could be problematic if you spam the move left/right/up/down button next to an impassable tile since it'd be saving a lot.
     

    Luka S.J.

    Jealous Croatian
    1,270
    Posts
    15
    Years
  • I'm not really going too much about how to optimize the functionality script, but I do have some pointers on the implementation. If you want to simply append or prepend just a couple of lines of code to a script, it would be best to alias the original function and reference the alias, instead of writing out the full function and adding your one liners. This would make the system more plug and play, and not interfere with the functionality should it be changed in the original script.
    Code:
    # This is the target class, no need to re-inherit from parent
    class Game_Player
      # alias and overwrite move DOWN
      alias move_down_autosave move_down unless self.method_defined?(:move_down_autosave)
      def move_down(*args)
        move_down_autosave(*args)
        pbSave
      end
    
      # alias and overwrite move LEFT
      alias move_left_autosave move_left unless self.method_defined?(:move_left_autosave)
      def move_left(*args)
        move_left_autosave(*args)
        pbSave
      end
    
      # alias and overwrite move RIGHT
      alias move_right_autosave move_right unless self.method_defined?(:move_right_autosave)
      def move_right(*args)
        move_right_autosave(*args)
        pbSave
      end
    
      # alias and overwrite move UP
      alias move_up_autosave move_up unless self.method_defined?(:move_up_autosave)
      def move_up(*args)
        move_up_autosave(*args)
        pbSave
      end
    end
     
    For me, it was a pain having to save my game each time I had to shut the console down...

    So, I made this script:
    Spoiler:
    Tell me if you have any errors!

    I want that the script should not run when the player is in Safari Zone Map or any other map where saving is prohibited. Because savig in a Safari Zone is a good way to save safari balls. LMAO
     
    Back
    Top