Resource icon

Switching between PC Storages 1.0

Pokémon Essentials Version
v17.2 ➖
This script makes it easy to change between any number of different pc storages. All you have to do is call
Code:
pbSwitchStorage(storageNumberPrevious,nextNumberPrevious)
every time you switch inbetween characters.

Disclaimer:
This script does not touch the Party.
This script does not allow to merge or move Pokémon inbetween storages. It just switches the entire storage out.
Each storage will be a basic Storage System. With all features that is associated with them. There is currently no option to allow changes like one storage slot having more total storage slots than another. I'm open for suggestions though ... if it's easy I'll probably extend this script.

Code:
#============================================================
#Pokémon Storage Switch script by leilou
#
#For Essentials 17.2; Version 1.0
#
#This script is ment to make it easy to alternate between storage systems
#
#Pokémon Essentials is created by Poccil, based on Flameguru's
#Pokémon Starter Kit and managed and updated by Maruno
#
#I don't claim this script to be perfect.
#Please report bugs at the resources thread on Relic Castle.
#=============================================================

#Slot in $game_variables that is used for this.
#Make sure to set this to game variables not used in any other way!
STORAGE_GAME_VARIABLE_USED = 51

#this function saves the current storage int slot storageNumberPrevious
#and loads the storage in slot storageNumberNext into the current storage
#if this is the first time calling that storage a new empty storage will be made
#   and set as the current storage
#storageNumberPrevious    Integer   The ID Number the current storage will be saved in.
#storageNumberNext        Integer   The ID Number of the storage that will be loaded.
#                                   A new storage will be initialized if there is no save with that ID.
#                         nil       If a new storage is to be made.
#returns true on success and false on failure
def pbSwitchStorage(storageNumberPrevious, storageNumberNext)
  #checks for invalid inputs
  if !$game_variables
    return false
  end
  if (storageNumberPrevious == storageNumberNext)
    return false
  end
  if (!storageNumberPrevious.is_a? Integer ||
      !(storageNumberNext.is_a? Integer || storageNumberNext.nil?))
    return false
  end
 
  #initialize game variable if not already happened:
  if !$game_variables[STORAGE_GAME_VARIABLE_USED].kind_of?(Array)
    $game_variables[STORAGE_GAME_VARIABLE_USED] = []
  end
 
  #save current party
  $game_variables[STORAGE_GAME_VARIABLE_USED][storageNumberPrevious]=$PokemonStorage
 
  #if no old storage was set make it a blank one else load the saved one
  if(storageNumberNext.nil? || !$game_variables[STORAGE_GAME_VARIABLE_USED][storageNumberNext])
    $PokemonStorage = PokemonStorage.new
  else
    $PokemonStorage = $game_variables[STORAGE_GAME_VARIABLE_USED][storageNumberNext]
  end
  #storage switched ... return true
  return true
end

Setting up this script:
  1. Insert this as a new script into the scripts section of your game.
  2. Change the variable STORAGE_GAME_VARIABLE_USED in line 17 (it'S the first variable in the script) to the variable in $game_variables you want to use for this. The number also equals the number in the set variales in the events. This is used to store unused Storages. You must not use that variable for anything else in your game.
  3. Insert
    Code:
    pbSwitchStorage(storageNumberPrevious,nextNumberPrevious)
    whenever you want to switch storages.
Parameters:
storageNumberPrevious:
Integer: The ID Number the current storage will be saved in. The ID can be any natural number as long as it's consistent within every single call of this function in your game.​
storageNumberNext:
Integer: The ID Number of the storage that will be loaded. A new storage will be initialized if there is no save with that ID. The ID can be any natural number as long as it's consistent within every single call of this function in your game.​
nil:If a new storage is to be made.​
returns true on success and false on failure

If you have any feedback, bugs, inspirations feel free to drop a comment and I'll see what I can do. Also if this thread is not easy to understand also tell me and I'll try to make it better.
Credits
Script by leilou
  • Like
Reactions: Ekat
Author
leilou
Downloads
86
Views
86
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from leilou

Top