• 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.

[17.2] PokéFile - Pokémon Import/Export/Transfer

55
Posts
4
Years
  • Age 34
  • Seen today
Supported versions: 17.2 and 18.0/18.1/18.dev

Code is a tad messy but I tried to add comments where possible to explain what's going on. Still a bit of a rookie scripter ^^'
At the moment there's bound to be some mistakes or functionality that could be added.
If someone has feedback for me or can improve on it, hit me up! 😊
Also please report any bugs you find!

Known Exploits:
This is a trading system so obviously people can exploit it to copy pokemon and items.
If people want to ruin their playthrough, just let them? Couldn't really think of a way of stopping this.

Please credit!
If you find use for this, please credit me for it in your game as TastyRedTomato.
The script is a very heavy rewrite of Hansiec's PVP script so credit them too.
Also check out their script, it's awesome and here on Pokécommunity as well.

Compatibility note!
If you change the way pokemon work internally beyond vanilla (eg add/remove stats or something), you 'll have to add/remove accessors and values to the package.
The script was written with vanilla essentials in mind and has some compatibility for Birthsigns and Shinyleaf by Lucidious89.
If you use one of those functions, set the flag in compatibility to true.

Cross-game trading is turned off by default, it can be turned on if you want to though.
When cross-game trading, it uses TRADE CODES. Make sure your PBS matches however!

In the future I definitely want to make it implement more compatibility/security checks to make the game more universal in usage.

What this script does:
* This script allows players to import and export .poke files which the script creates.
* The poke files contain a large amount of data from a pokemon of the player's choice.
* The files are created and loaded from a "Transfer" folder.
* Players can share files from this folder with each other.
* Exporting the pokemon, removes the selected pokemon and creates a new file.
* Importing the pokemon, removes the file and adds the selected pokemon to the party.
* Optional trade evolutions (golem, steelix, etc)
* Trade with any games you make compatible with one another

Why I made it:
There's really not much out there for trading and I didn't feel like setting up an online mysql database.
This is, for me personally, an easier to implement alternative to something like that.

How to install/use:
*Create a new empty folder in your root game folder (the one where game.rxproj sits) and name it "Transfer"
*Copy the script, paste it above Main and call it PokeFile
*Call the scriptline "POKEFILE.open" either in an event or another script (for example pokégear)

The code:
Code:
################################################################################
#  PokéFile by TastyRedTomato
#---------------------------------------
# based very loosely on the PVP script by Hansiec
# minor additions by Xeevee10
# please credit when used
# 
# To use:
#   * Create a folder in your game's folder called "Transfer"
#   * Paste this script above Main
#   * Call "POKEFILE.open" in a script (add to pokegear or NPC)
#
# There are two options when calling the script. 
#  - Create Pokemon Data exports the data of a chosen pokemon to a .poke file and
#    removes the Pokémon from your party.
#  - Load Pokemon Data imports the data from the .poke file and adds it to your
#    party when possible and deletes the specific .poke file.
#
#-------------------------------------------------------------------------------
# Compatibility options
#-------------------------------------------------------------------------------
#
BIRTHSIGNS_SCRIPT = false #set to true when using birthsigns by Lucidious89
SHINYLEAF = false #set to true when using the shinyleaf either independently or in birthsigns
#
#-------------------------------------------------------------------------------
# Other options
#-------------------------------------------------------------------------------
#
GAMECODE_USE = false #set to true when using a game code
GAMECODE = "gamecode" #change this when using the game code to trade between different fangames
TRADEEVOLUTION = true #set to true if you want trade evolutions
#
#------------------------------------------------------------------------------------
# How to add new values (new stats, attributes, however you changed the way mons work
#------------------------------------------------------------------------------------
#
# 1) In class PokemonPackage, add "attr_accessor :nameofyourvalue"
# 2) In module POKEFILECore, go to the comment "#Generate new package".
#    There you add tp.nameofyourvalue = the getter of your value
# 3  Go to def self.loadPokemon(file), at the point where it returns an array with all the data,
#    add your tp.nameofyourvalue after the last one. Note the index in the array.
# 4) Scroll towards the bottom of the script at the comment "#generate pokemon from file",
#    Where the pokemon is generated, add the setter for your new value and use the 
#    pokemon[index]. Take a look at how the existing data is handled if you need examples.
#
#
#------------------------------------------------------------------------------------
# How to make the system cross-fangame 
#(note: only use between fangames that use the same version of this script)
#------------------------------------------------------------------------------------
#
# Set GAMECODE_USE to true.
# Fill out a game code of your choice (preferably one that's hard to guess)
# Do the same for your other game.
# If there are mismatches in the PBS files of both games it will give errors.
#
################################################################################



class PokemonPackage
  attr_accessor :pokemon
  attr_accessor :game_code
  attr_accessor :poke
  #------------------------
  attr_accessor :species
  attr_accessor :ability
  attr_accessor :ballused
  attr_accessor :EV
  attr_accessor :form
  attr_accessor :gender
  attr_accessor :happiness
  attr_accessor :helditem
  attr_accessor :IV
  attr_accessor :language
  attr_accessor :level
  attr_accessor :moveset
  attr_accessor :nature
  attr_accessor :nickname
  attr_accessor :obtaintext
  attr_accessor :pokerus
  attr_accessor :ribbons
  attr_accessor :shadow
  attr_accessor :shiny
  attr_accessor :beauty
  attr_accessor :cool
  attr_accessor :cute
  attr_accessor :smart
  attr_accessor :tough
  attr_accessor :sheen
  attr_accessor :curhp
  attr_accessor :eggsteps
  attr_accessor :exp
  attr_accessor :fused
  attr_accessor :hatchmap
  attr_accessor :hatchtime
  attr_accessor :markings
  attr_accessor :obtainlvl
  attr_accessor :obtainmap
  attr_accessor :obtainmethod
  attr_accessor :trainergender
  attr_accessor :trainerid
  attr_accessor :trainername
  attr_accessor :pokemonid
  attr_accessor :status
  attr_accessor :mail
  #--------------------------
  #compatibilities
  #--------------------------
  #birthsigns/shinyleaf by Lucidious89
  attr_accessor :birthsign 
  attr_accessor :celestial
  attr_accessor :blessed
  attr_accessor :shinyleaf
end

module POKEFILE
  def self.open
    Dir.mkdir("Transfer\\") unless File.exists?("Transfer\\")
    loop do
      commands = []
      commands[cmdDump=commands.length] = "Create Pokémon Data"
      commands[cmdBattle=commands.length] = "Load Pokémon Data"
      commands[cmdExit=commands.length] = "Exit"
      choice = Kernel.pbMessage(_INTL("Welcome to the Transfer station, how may I help you?"),
      commands, 0, nil, 0)
      if choice == cmdDump
        if $Trainer.ablePokemonParty.length > 1 #stops players from export if they have only 1 able pokemon
          Kernel.pbMessage(_INTL("Warning, exporting your Pokémon will overwrite any existing savegames.")) 
          Kernel.pbMessage(_INTL("Warning, this may overwrite existing Pokémon Data for this trainer. Press action to continue.")) 
          if POKEFILECore.createPokeFile
            Kernel.pbMessage(_INTL("Pokémon Data was created in the Transfer folder."))
            Kernel.pbMessage(_INTL("Your game has been saved."))
          else
              Kernel.pbMessage(_INTL("Could not make pokémon data or no pokémon was selected."))
          end
        else
        Kernel.pbMessage(_INTL("You don't have enough able Pokémon in your party right now. A minimum of 2 Pokémon is required.")) 
        end
      elsif choice == cmdBattle
        files = ["Cancel"]
        Dir.chdir("Transfer"){
          Dir.glob("*.poke"){|f|
            files.push(f)
          }
        }
        choice = Kernel.pbMessage(_INTL("select a pokémon file"), files, -1, nil, 0)
        if choice >= 1
          Kernel.pbMessage(_INTL("Warning, importing a Pokémon will overwrite any existing savegames.")) 
          Kernel.pbMessage(_INTL("Warning, this will delete the Pokémon Data for this trainer. Press action to continue.")) 
          file = "Transfer/" + files[choice]
          pokemon = POKEFILECore.loadPokemon(file)
          if pokemon
            if POKEFILECore.addpoke(pokemon)
               File.delete("Transfer/" + files[choice]) if File.exist?("Transfer/" + files[choice])
            end
          else
            Kernel.pbMessage(_INTL("Cannot load pokémon file..."))
          end
        end
      elsif choice == cmdExit
        break
      end
    end
  end


module POKEFILECore
   def self.createPokeFile
    pbChooseTradablePokemon(1,3)
    if $game_variables[1] == -1
      return
    end
    pokechoice = $Trainer.party[$game_variables[1]].clone
    pbRemovePokemonAt($game_variables[1])
    return dumpPokemon(pokechoice)
  end
    
  def self.dumpPokemon(pokechoice) #saves data into a poke file
    f = File.open("Game.ini")
    lines = f.readlines()
    s = lines[3]
    len = s.size
    title = (s[6,len - 7])
    f.close
    #Generate new package
    tp = PokemonPackage.new
    tp.pokemon = $Pokemon
    tp.game_code = title if GAMECODE_USE == false
    tp.game_code = GAMECODE if GAMECODE_USE == true
    tp.poke = pokechoice
    #----------------------------------
    tp.species = pokechoice.species
    tp.ability = pokechoice.ability
    tp.ballused = pokechoice.ballused
    tp.EV = [pokechoice.ev[0],pokechoice.ev[1],pokechoice.ev[2],pokechoice.ev[3],pokechoice.ev[4],pokechoice.ev[5]]
    tp.form = pokechoice.form
    tp.gender = pokechoice.gender
    tp.happiness = pokechoice.happiness
    tp.helditem = pokechoice.item
    tp.IV = [pokechoice.iv[0],pokechoice.iv[1],pokechoice.iv[2],pokechoice.iv[3],pokechoice.iv[4],pokechoice.iv[5]]
    tp.language = pokechoice.language
    tp.level = pokechoice.level
    tp.moveset = [pokechoice.moves[0],pokechoice.moves[1],pokechoice.moves[2],pokechoice.moves[3]]
    tp.nature = pokechoice.nature
    tp.nickname = pokechoice.name
    tp.obtaintext = pokechoice.obtainText
    tp.pokerus = pokechoice.pokerus
    tp.shiny = pokechoice.isShiny?
    tp.shadow = pokechoice.isShadow?
    tp.beauty = pokechoice.beauty
    tp.cool = pokechoice.cool
    tp.cute = pokechoice.cute
    tp.smart = pokechoice.smart
    tp.tough = pokechoice.tough
    tp.sheen = pokechoice.sheen
    tp.curhp = pokechoice.hp
    tp.eggsteps = pokechoice.eggsteps
    tp.exp = pokechoice.exp
    tp.fused = pokechoice.fused
    tp.hatchmap = pokechoice.hatchedMap
    tp.hatchtime = pokechoice.timeEggHatched
    tp.markings = pokechoice.markings
    tp.obtainlvl = pokechoice.level #sets the obtain level to the current level
    tp.obtainmap = $game_map.map_id #sets the obtain location to the current map
    tp.obtainmethod = 2 #sets the obtain mode to traded
    tp.trainergender = pokechoice.otgender
    tp.trainerid = pokechoice.trainerID
    tp.trainername = pokechoice.ot
    tp.pokemonid = pokechoice.personalID
    tp.status = pokechoice.status
    tp.ribbons = pokechoice.ribbons
    tp.mail = pokechoice.mail
    #birthsigns compatibility
    if BIRTHSIGNS_SCRIPT == true
      tp.birthsign = pokechoice.zodiacflag
      tp.celestial = pokechoice.celestial
      tp.blessed = pokechoice.blessed
    else
       tp.birthsign = nil
       tp.celestial = nil
       tp.blessed = nil
    end
    if SHINYLEAF == true
      tp.shinyleaf = pokechoice.leafflag
    else
      tp.shinyleaf = nil
    end
    
    save_data(tp, "Transfer/#{$Trainer.name}'s Lv.#{tp.level} #{pokechoice.name} (#{pokechoice.iv[0]}#{pokechoice.iv[1]}#{pokechoice.iv[2]}).poke")
    pbSave
    return true
  rescue
    return nil
  end
  
  def self.loadPokemon(file) #loads the data and puts it into an array
    f = File.open("Game.ini")
    lines = f.readlines()
    s = lines[3]
    len = s.size
    title = (s[6,len - 7])
    f.close
    tp = load_data(file)
    if GAMECODE_USE == false
      return false if tp.game_code != title #checks if the game is the same
    end
    if GAMECODE_USE == true
      return false if tp.game_code != GAMECODE #checks if the game code is the same
    end
    return [tp.pokemon, tp.game_code, tp.poke, #0-2    returns an array containing the file data
            tp.species, tp.ability, tp.ballused, tp.EV, tp.form, tp.gender, #3-8
            tp.happiness, tp.helditem, tp.IV, tp.language, tp.level, tp.moveset,#9-14
            tp.nature, tp.nickname, tp.obtaintext, tp.pokerus, tp.shiny, tp.shadow,#15-20
            tp.beauty, tp.cool, tp.cute, tp.smart, tp.tough, tp.sheen, tp.curhp,#21-27
            tp.eggsteps, tp.exp, tp.fused, tp.hatchmap, tp.hatchtime, tp.markings,#28-33
            tp.obtainlvl, tp.obtainmap, tp.obtainmethod, tp.trainergender,#34-37
            tp.trainerid, tp.trainername, tp.pokemonid, tp.status,tp.ribbons,tp.mail,#38-43
            #compatibilities
            tp.birthsign,tp.celestial,tp.blessed,tp.shinyleaf]#44-47 birthsign/shinyleaf compatibility
  rescue
    return nil
  end
  
  def self.addpoke(file)
    pokemon = file
    pokemon = loadPokemon(file) if !file.is_a?(Array)
   if !pokemon
     Kernel.pbMessage(_INTL("Could not add the Pokémon. Check file integrity."))
      return false 
    end
   #generate pokemon from file
   pkmn = pbGenPkmn(pokemon[3],pokemon[13]) #generate pokemon with species and level
   pkmn.ballused=pokemon[5] #sets the ball type
   pkmn.ev[0]=pokemon[6][0] #ev1
   pkmn.ev[1]=pokemon[6][1] #ev2
   pkmn.ev[2]=pokemon[6][2] #ev3
   pkmn.ev[3]=pokemon[6][3] #ev4
   pkmn.ev[4]=pokemon[6][4] #ev5
   pkmn.ev[5]=pokemon[6][5] #ev6
   pkmn.form = pokemon[7] #set pokemon form
   if pokemon[8] == 0 #male pokemon
     pkmn.makeMale
   elsif pokemon[8] == 1 #female pokemon
     pkmn.makeFemale
   else
     pkmn.setGender(nil) #other genders catchall (leges etc)
   end
   pkmn.happiness = pokemon[9] #set pokemon happiness
   pkmn.setItem(pokemon[10]) #set the item a pokemon holds
   pkmn.iv[0]=pokemon[11][0] #iv1
   pkmn.iv[1]=pokemon[11][1] #iv2
   pkmn.iv[2]=pokemon[11][2] #iv3
   pkmn.iv[3]=pokemon[11][3] #iv4
   pkmn.iv[4]=pokemon[11][4] #iv5
   pkmn.iv[5]=pokemon[11][5] #iv6
   pkmn.language = pokemon[12] #sets the language of the pokemon
   pkmn.moves[0] = pokemon[14][0] #sets the first move of the pokemon
   pkmn.moves[1] = pokemon[14][1] #sets the second move of the pokemon
   pkmn.moves[2] = pokemon[14][2] #sets the third move of the pokemon
   pkmn.moves[3] = pokemon[14][3] #sets the fourth move of the pokemon
   pkmn.setNature(pokemon[15]) #sets the pokemon's nature
   if pokemon[16] != pkmn.species && pokemon[16].is_a?(String) && pokemon[16].size > 0
      pkmn.name = pokemon[16]
   end
   pkmn.obtainText=_I("Pokémon Transfer") #sets pokemon source
   pkmn.pokerus = pokemon[18]
   if pokemon[19] == true #makes pokemon shiny if it should be
     pkmn.makeShiny
   end
   if pokemon[20] == true #makes pokemon shadow if it should be
     pkmn.makeShadow
   end
   pkmn.beauty = pokemon[21] #set pokemon beauty value
   pkmn.cool = pokemon[22] #set pokemon cool value
   pkmn.cute = pokemon[23] #set pokemon cute value
   pkmn.smart = pokemon[24] #set pokemon smart value
   pkmn.tough = pokemon[25] #set pokemon tough value
   pkmn.sheen = pokemon[26] #set pokemon sheen value
   pkmn.hp = pokemon[27] #sets the pokemon's current hp
   pkmn.eggsteps = pokemon[28] #sets the steps required to hatch, failsafe, unable to trade eggs normally
   pkmn.exp = pokemon[29] #sets current exp
   pkmn.fused = pokemon[30] #sets fused pokemon
   pkmn.hatchedMap = pokemon[31] #sets hatched map id if pokemon came from egg
   pkmn.timeEggHatched = pokemon[32] #time at which it hatched, will not be shown because method is traded
   pkmn.markings = pokemon[33] #markings of the pokemon
   pkmn.obtainMode=2 #method 2, traded
   pkmn.otgender= pokemon[37] #original trainer gender
   pkmn.trainerID = pokemon[38] #original trainer id
   pkmn.ot = pokemon[39] #original trainer name
   pkmn.personalID = pokemon[40] #sets the pokemon ID (used in calculation of ability, gender and nature)
   pkmn.status= pokemon[41] #sets pokemon status ailment
   pkmn.ribbons = pokemon[42] #sets pokemon ribbons
   pkmn.mail = pokemon[43] #sets mail items data
   if BIRTHSIGNS_SCRIPT == true
     pkmn.zodiacflag = pokemon[44] #sets the pokemon's birthsign/zodiac
     pkmn.celestial = pokemon[45] #sets whether a pokemon is celestial or not
     pkmn.blessed = pokemon[46] #sets whether a pokemon is blessed or not
   end
   if SHINYLEAF == true
     pkmn.leafflag = pokemon[47] #sets the pokemon shiny leaf value
   end
   pkmn.calcStats
   if pbAddToPartySilent(pkmn) #this checks if the pokemon can be added to the party and adds it if possible
     if TRADEEVOLUTION #plays the trade evolution scene when all conditions have been met
       newspecies = pbTradeCheckEvolution(pkmn, pkmn.item)
       if newspecies > 0
        evo = PokemonEvolutionScene.new
        evo.pbStartScreen(pkmn, newspecies)
        evo.pbEvolution
        evo.pbEndScreen
       end
     end
     pbSave
     Kernel.pbMessage(_INTL("The Pokémon was added to your party."))
     Kernel.pbMessage(_INTL("Your game has been saved."))
    return true
   else
    Kernel.pbMessage(_INTL("Could not add the pokémon to party. Make sure you have enough space."))
    return false
   end
 end
end
end
 
Last edited:
55
Posts
4
Years
  • Age 34
  • Seen today
Cool, can you make it combatible with birthsigns?

I'll have to look at the birthsigns script to see how they store the data but sure, it shouldn't be too hard to make birthsigns compatibility.

EDIT: made the changes, it's now compatible. Just set the necessary flags near the start of the script to true when you use Birthsigns or shinyleaf.
 
Last edited:
1
Posts
4
Years
  • Age 34
  • Seen Feb 12, 2022
I really appreciate this script! I added a simple modification for my own personal use, but others can use it here:

I replaced line 242
Code:
    save_data(tp, "Transfer/#{$Trainer.name}'s Pokemon.poke")
with
Code:
    save_data(tp, "Transfer/#{$Trainer.name}'s Lv.#{tp.level} #{pokechoice.name} (#{pokechoice.iv[0]}#{pokechoice.iv[1]}#{pokechoice.iv[2]}).poke")

It allows for an infinite number of Pokemon to be transferred/stored at a single time, and displays the name and level of the Pokemon. In addition, it generates a code based of the first 3 IVs of the Pokemon to ensure that the Pokemon isn't overwritten. The IVs at the end of the script could be replaced with one segment that contains the Pokemon's personal id, but I did it my way because it looks better in-game.
 
55
Posts
4
Years
  • Age 34
  • Seen today
I really appreciate this script! I added a simple modification for my own personal use, but others can use it here:

I replaced line 242
Code:
    save_data(tp, "Transfer/#{$Trainer.name}'s Pokemon.poke")
with
Code:
    save_data(tp, "Transfer/#{$Trainer.name}'s Lv.#{tp.level} #{pokechoice.name} (#{pokechoice.iv[0]}#{pokechoice.iv[1]}#{pokechoice.iv[2]}).poke")

It allows for an infinite number of Pokemon to be transferred/stored at a single time, and displays the name and level of the Pokemon. In addition, it generates a code based of the first 3 IVs of the Pokemon to ensure that the Pokemon isn't overwritten. The IVs at the end of the script could be replaced with one segment that contains the Pokemon's personal id, but I did it my way because it looks better in-game.

This is a great idea, I edited the script as such, and changed the dialogue as well to make sense with it. (+credit)
Added an option as well named TRADEEVOLUTION which allows you to toggle trade evolutions when using the transfer system and a message when the Pokémon evolved.
 
80
Posts
4
Years
  • Age 24
  • Seen Nov 5, 2023
I do not know why, but when I use the script. NICKNAMES do not carry over... I do not know why that is
And in the filename is the nickname ex."AAAA's Lv.22 norA (271122).poke" but when I then transfer it back, it has no nickname

EDIT: As I tested to evolve Steelix and then go into the Pokémon Screen the game glitched, it may has something to do with me usign EBS or because it took the Metal Coat from Steelix
 
Last edited:
971
Posts
7
Years
  • Age 21
  • Seen Nov 28, 2022
You'd probably want to change this:
Code:
   if pkmn.name != pkmn.speciesName 
     pkmn.name = pokemon[16] #sets the pokemon's nickname if it has one
   end

into this
Code:
pkmn.name = pokemon[16] # Set nickname regardless of whether it's equal to the species name


Although honestly, I don't know why you'd not just Marshal.dump the entire pokemon to a file, rather than make a new class to do so. That way you don't have to make any new classes, you don't have to write down all the properties three times (defining, writing and reading), and it works with all third party scripts.
 
55
Posts
4
Years
  • Age 34
  • Seen today
You'd probably want to change this:
Code:
   if pkmn.name != pkmn.speciesName 
     pkmn.name = pokemon[16] #sets the pokemon's nickname if it has one
   end

into this
Code:
pkmn.name = pokemon[16] # Set nickname regardless of whether it's equal to the species name


Although honestly, I don't know why you'd not just Marshal.dump the entire pokemon to a file, rather than make a new class to do so. That way you don't have to make any new classes, you don't have to write down all the properties three times (defining, writing and reading), and it works with all third party scripts.

I found that using your version of the name code somehow set the nickname to the species name and didn't change it when evolving. For example, when graveler would evolve to golem, it would keep the name graveler, probably because its nickname was "graveler". It might just be some oversight on my part though? You probably know more about coding in essentials than me :p

As for using Marshal.dump, I'm pretty new to ruby and coding in general so this version worked best for me personally, limited to what I know about coding (which is not much). I just wanted to share it with folks out there so they could build off it or simply add this feature to their fangames. Will try to look into the marshal dump thing though cuz it seems interesting.
It would be great if someone really well versed at coding would publish a trading/transfer script. 😊
 
971
Posts
7
Years
  • Age 21
  • Seen Nov 28, 2022
I found that using your version of the name code somehow set the nickname to the species name and didn't change it when evolving. For example, when graveler would evolve to golem, it would keep the name graveler, probably because its nickname was "graveler". It might just be some oversight on my part though? You probably know more about coding in essentials than me :p

As for using Marshal.dump, I'm pretty new to ruby and coding in general so this version worked best for me personally, limited to what I know about coding (which is not much). I just wanted to share it with folks out there so they could build off it or simply add this feature to their fangames. Will try to look into the marshal dump thing though cuz it seems interesting.
It would be great if someone really well versed at coding would publish a trading/transfer script. 😊

It's good that you make things like this nonetheless, because practising is the only way to improve.

As for the code, you'd probably do this, if I'm understanding the issue correctly:
Code:
if pokemon[16] != PBSpecies.name(pkmn.species) && pokemon[16].is_a?(String) && pokemon[16].size > 0
  pkmn.name = pokemon[16]
end

I don't know without checking if the nickname is nil or just empty if it's not set, so I added a check for it to be a string and to make sure it's not an empty string.
 
55
Posts
4
Years
  • Age 34
  • Seen today
I do not know why, but when I use the script. NICKNAMES do not carry over... I do not know why that is
And in the filename is the nickname ex."AAAA's Lv.22 norA (271122).poke" but when I then transfer it back, it has no nickname

EDIT: As I tested to evolve Steelix and then go into the Pokémon Screen the game glitched, it may has something to do with me usign EBS or because it took the Metal Coat from Steelix

The nickname issue should be solved now. It was an error where the script would check for a nickname but always return false no matter what.

As for steelix, I believe the problem lies with the fact that it tries to take its item (see pscreen_trading script) without the pokemon being in the party yet at that point.
I'm looking into it but until then I'll consider trade_evolutions bugged.
 
55
Posts
4
Years
  • Age 34
  • Seen today
It's good that you make things like this nonetheless, because practising is the only way to improve.

As for the code, you'd probably do this, if I'm understanding the issue correctly:
Code:
if pokemon[16] != PBSpecies.name(pkmn.species) && pokemon[16].is_a?(String) && pokemon[16].size > 0
  pkmn.name = pokemon[16]
end

I don't know without checking if the nickname is nil or just empty if it's not set, so I added a check for it to be a string and to make sure it's not an empty string.

Thank you for the reply ^^
I hadn't thought of adding the string check too so added that as well now.
 
80
Posts
4
Years
  • Age 24
  • Seen Nov 5, 2023
Well, I added a in game trade for a Slowpoke that evolves into slowking, it cannot be that hard, could you maybe add that when the user wants that ITEMS will not be transfered but put back in the bag. That would lead to that the ITEM TRADE EVOLUTION GLITCH cannot be encountered
 
55
Posts
4
Years
  • Age 34
  • Seen today
Well, I added a in game trade for a Slowpoke that evolves into slowking, it cannot be that hard, could you maybe add that when the user wants that ITEMS will not be transfered but put back in the bag. That would lead to that the ITEM TRADE EVOLUTION GLITCH cannot be encountered

Fixed the trade evolutions, they also have the evolution animation now. Let me know if you encounter any more glitches!
(note: everstones will also stop evolutions in this system)
 
Last edited:

#Not Important

All hail the wishmaker
910
Posts
4
Years
To prevent dupes, assign a personal id to each Pokemon. Here's the code I would use:
Code:
class PokeFile_Vars
  attr_accessor :idDone #The variable that stores the id's given.
  def initialize
    @idDone=[]
  end
end
And in your code
Code:
var = rand(9999999)
for i in PokeFile_Vars.idDone
  unless i==var
    pokemon[48] = var
    PokeFile_Vars.idDone.push(var)
  end
end
 
55
Posts
4
Years
  • Age 34
  • Seen today
To prevent dupes, assign a personal id to each Pokemon. Here's the code I would use:
Code:
class PokeFile_Vars
  attr_accessor :idDone #The variable that stores the id's given.
  def initialize
    @idDone=[]
  end
end
And in your code
Code:
var = rand(9999999)
for i in PokeFile_Vars.idDone
  unless i==var
    pokemon[48] = var
    PokeFile_Vars.idDone.push(var)
  end
end

This would still be problematic if you got a mon from another person that happens to have rolled a same id, essentially blocking an otherwise legit trade.
 

Mr.Paradox

Mr.Paradox
104
Posts
5
Years
  • Age 30
  • Seen today
hey man it's cool script but i still don't get it like if i have 2 fan games if i finished one and started the other,will this script allow me to transfer my pokemon from the first game to my other one and if so how
 
55
Posts
4
Years
  • Age 34
  • Seen today
hey man it's cool script but i still don't get it like if i have 2 fan games if i finished one and started the other,will this script allow me to transfer my pokemon from the first game to my other one and if so how

The script as it is only allows you to transfer between the same fangames. ("pokemon blue" to "pokemon blue")

If you want to transfer between different fan games you need to either remove or edit this line where it checks for the fangame:
Code:
return false if tp.game_code != title #checks if the game is the same, remove if you want to risk cross-platform

1) Removing it will allow any poke-file to be imported, including from other games. This can be a problem if it has non-matching PBS files (importantly: everything to do with pokemon,forms, items...), most likely resulting in errors (the error will depend on the differences).
(pokemon blue to red and back should work fine, trading with other fangames will bork it with errors if their PBS is different)

2) Alternatively you can add an AND parameter where it checks for your other game titles to see whether it matches any of the other titles you want to include in your trades/transfers.
Something like:
Code:
return false if tp.game_code != title && tp.game_code != (whatever title value your other game has)
(in this case, pokemon blue and red can trade, they will refuse any mons from other games)

3) Another alternative would be to forego this method entirely and use the following method:
Change the line:
Code:
tp.game_code = title
to
Code:
tp.game_code = imaginarytradecodeofyourgames
and change the line:
Code:
return false if tp.game_code != title
to
Code:
return false if tp.game_code != imaginarytradecodeofyourgames
Use a string for this tradecode, it can be any word or whatever of your choice. This will allow all games with the same trade codes to trade with one another.
(in this case, pokemon blue and red can trade, they will refuse any mons from other games)

EDIT: I'll update the script to easily make use of these tradecodes, no editing of the script required now.
 
Last edited:
80
Posts
4
Years
  • Age 24
  • Seen Nov 5, 2023
Hey, I would like to do it so that for two of my older Fangames it will be a oneway trip. Can you edit the script so that I can make it that way please? Like a
onlyexpert = true or false
thing
 
55
Posts
4
Years
  • Age 34
  • Seen today
Hey, I would like to do it so that for two of my older Fangames it will be a oneway trip. Can you edit the script so that I can make it that way please? Like a
onlyexpert = true or false
thing

You can use the GAMECODE for it. Use the existing version of the script for your old games, and activate gamecode, then for the new one:
Where it says GAMECODE = "gamecode" near the top of the script, add:
Code:
GAMECODE2 = "gamecode2"
GAMECODE3 = "gamecode3"

On the line that says: return false if tp.game_code != GAMECODE
change the line to the following snippet:
Code:
unless [GAMECODE,GAMECODE2,GAMECODE3].include? tp.game_code #checks whether the array of game codes includes the code from other games (GAMECODE2 and GAMECODE3)
return false
end


gamecode2 and gamecode3 will be the gamecodes you used for the older games.
You can keep adding game codes like that as long as you define them near the top and add them to the array.
 
277
Posts
15
Years
Spoiler:

This script is amazing, can't wait to use it!
I have a solution to prevent your script from giving an error or deleting Pokemon if the player does not have a folder named "Transfer" in their game folder.
Check if the folder exists and if it folder does not exist, then have PokeFile create it.

add whats in red to the following Module:
Code:
module POKEFILE
  def self.open
    [COLOR="Red"]Dir.mkdir("Transfer\\") unless File.exists?("Transfer\\")[/COLOR]
    loop do
      commands = []
      commands[cmdDump=commands.length] = "Create Pokémon Data"
      commands[cmdBattle=commands.length] = "Load Pokémon Data"
      commands[cmdExit=commands.length] = "Exit"
      choice = Kernel.pbMessage(_INTL("Welcome to the Transfer station, how may I help you?"),
      commands, 0, nil, 0)
      if choice == cmdDump
        if $Trainer.ablePokemonParty.length > 1 #stops players from export if they have only 1 able pokemon
          Kernel.pbMessage(_INTL("Warning, exporting your Pokémon will overwrite any existing savegames.")) 
          Kernel.pbMessage(_INTL("Warning, this may overwrite existing Pokémon Data for this trainer. Press action to continue.")) 
          if POKEFILECore.createPokeFile
            Kernel.pbMessage(_INTL("Pokémon Data was created in the Transfer folder."))
            Kernel.pbMessage(_INTL("Your game has been saved."))
          else
              Kernel.pbMessage(_INTL("Could not make pokémon data or no pokémon was selected."))
          end
        else
        Kernel.pbMessage(_INTL("You don't have enough able Pokémon in your party right now. A minimum of 2 Pokémon is required.")) 
        end
      elsif choice == cmdBattle
        files = ["Cancel"]
        Dir.chdir("Transfer"){
          Dir.glob("*.poke"){|f|
            files.push(f)
          }
        }
        choice = Kernel.pbMessage(_INTL("select a pokémon file"), files, -1, nil, 0)
        if choice >= 1
          Kernel.pbMessage(_INTL("Warning, importing a Pokémon will overwrite any existing savegames.")) 
          Kernel.pbMessage(_INTL("Warning, this will delete the Pokémon Data for this trainer. Press action to continue.")) 
          file = "Transfer/" + files[choice]
          pokemon = POKEFILECore.loadPokemon(file)
          if pokemon
            if POKEFILECore.addpoke(pokemon)
               File.delete("Transfer/" + files[choice]) if File.exist?("Transfer/" + files[choice])
            end
          else
            Kernel.pbMessage(_INTL("Cannot load pokémon file..."))
          end
        end
      elsif choice == cmdExit
        break
      end
    end
  end
 
Back
Top