• 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!
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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] [RESOLVED] Pulling Species number from a file (Essentials BW 3.1.1)

[RESOLVED]

So, I've made some custom code for Essentials BW 3.1.1, which is very loosely based of the MysteryGift code.
The first function, pbSaveImport, is supposed to take a file, extract the string, convert it into a pokemon, and clear the file.
Another function, pbMenuExport, is supposed to take a pokemon, convert it into a long string, and save it into that file.
But. I've been getting this error, and I can't track it down in the code.
Code:
Exception: ArgumentError
Message: The species number (no. 0 of 650) is invalid.
PokeBattle_Pokemon:861:in `__mf_initialize'
Pokemon_MultipleForms:114:in `initialize'
ExportImport:70:in `new'
ExportImport:70:in `pbSaveImport'
Debug:857:in `pbDebugMenu'
Debug:300:in `loop'
Debug:862:in `pbDebugMenu'
Debug:996:in `main'
Main:54:in `mainFunctionDebug'
Main:26:in `mainFunction'

I'm almost positive it's not the extraction because when I change it to the next value, the personal ID, I got the same error but with the ID instead.
Code:
Exception: ArgumentError
Message: The species number (no. 3547729879 of 650) is invalid.
PokeBattle_Pokemon:861:in `__mf_initialize'
Pokemon_MultipleForms:114:in `initialize'
ExportImport:70:in `new'
ExportImport:70:in `pbSaveImport'
Debug:855:in `pbDebugMenu'
Debug:300:in `loop'
Debug:862:in `pbDebugMenu'
Debug:996:in `main'
Main:54:in `mainFunctionDebug'
Main:26:in `mainFunction'

Code
Spoiler:

Thank you in advanced for any help. (It's probably something really small and stupid.)

EDIT: For what it's worth, the issue seems to be passing the values to the Initialization because hardcoding the species gave me this error for the level.
Code:
Exception: ArgumentError
Message: The level number (0) is invalid.
PokeBattle_Pokemon:131:in `level='
PokeBattle_Pokemon:906:in `__mf_initialize'
Pokemon_MultipleForms:114:in `initialize'
ExportImport:70:in `new'
ExportImport:70:in `pbSaveImport'
Debug:857:in `pbDebugMenu'
Debug:300:in `loop'
Debug:862:in `pbDebugMenu'
Debug:996:in `main'
Main:54:in `mainFunctionDebug'
 
Last edited:
You're trying to turn a string "MEW" into an integer. Ruby doesn't know that "MEW" (in string format) is the same as "150"


Edit:

It appears as if that was actually not the case. I made an assumption without looking at the code. I will look further into it.
 
Last edited:
You're trying to turn a string "MEW" into an integer. Ruby doesn't know that "MEW" (in string format) is the same as "150"

That is not what I'm doing. The Initial MEW is the game's id, for cross-game trading (If I ever use it). My example export is a Magikarp and is the bolded section.
Code:
MEW]//sp//]17]//sp//]2]//sp//]19]//sp//]28]//sp//]0]//sp//]16]//sp//]0]//sp//]0]//sp//]0]//sp//]0]//sp//]0]//sp//]0]//sp//][B]129[/B]]//sp//]1561824254]//sp//]195063392]//sp//]]//sp//]0]//sp//]]//sp//]Magikarp]//sp//]1250]//sp//]70]//sp//]0]//sp//]0]//sp//]0]//sp//]410*40*0]//sp//]0**]//sp//]0**]//sp//]0**]//sp//]410]//sp//]]//sp//]]//sp//]]//sp//]0]//sp//]0]//sp//]33]//sp//]]//sp//]10]//sp//]0]//sp//]2]//sp//]Example]//sp//]0]//sp//]]//sp//]]//sp//]]//sp//]]//sp//]]//sp//]3]//sp//]9]//sp//]2016]//sp//]]//sp//]10]//sp//]0
 
That is not what I'm doing. The Initial MEW is the game's id, for cross-game trading (If I ever use it). My example export is a Magikarp and is the bolded section.
Code:
MEW]//sp//]17]//sp//]2]//sp//]19]//sp//]28]//sp//]0]//sp//]16]//sp//]0]//sp//]0]//sp//]0]//sp//]0]//sp//]0]//sp//]0]//sp//][B]129[/B]]//sp//]1561824254]//sp//]195063392]//sp//]]//sp//]0]//sp//]]//sp//]Magikarp]//sp//]1250]//sp//]70]//sp//]0]//sp//]0]//sp//]0]//sp//]410*40*0]//sp//]0**]//sp//]0**]//sp//]0**]//sp//]410]//sp//]]//sp//]]//sp//]]//sp//]0]//sp//]0]//sp//]33]//sp//]]//sp//]10]//sp//]0]//sp//]2]//sp//]Example]//sp//]0]//sp//]]//sp//]]//sp//]]//sp//]]//sp//]]//sp//]3]//sp//]9]//sp//]2016]//sp//]]//sp//]10]//sp//]0


From what I can gather, the script works fine in loading and unloading the Pokemon.

I only get the error when trying to load the Pokemon twice in a row without resetting the text file.

Also, as another note: You left a few fields "status" and "statusCount" as raw strings. As well as "mail" is neither a string nor an integer, so you're going to need to find a way to wrap around that, too.

Otherwise, I think the issue may be because you're trying to load a blank file.


Edit:

Also, do you need it in this format? Why don't you just use the Mystery Gift functions to turn the Pokemon into a string, and vice-versa?
 
From what I can gather, the script works fine in loading and unloading the Pokemon.

I only get the error when trying to load the Pokemon twice in a row without resetting the text file.

Also, as another note: You left a few fields "status" and "statusCount" as raw strings. As well as "mail" is neither a string nor an integer, so you're going to need to find a way to wrap around that, too.

Otherwise, I think the issue may be because you're trying to load a blank file.


Edit:

Also, do you need it in this format? Why don't you just use the Mystery Gift functions to turn the Pokemon into a string, and vice-versa?

Oh my god, I love you. I found the problem was when I overwrote the file. Taking that out fixed it. (Kind of, crashed on opening the party screen but this was what was bothering me.)
And I didn't just use the Mystery Gift functions because the one that comes with Essentials BW is limited and effectively creates a new pokemon with new stats, because of not setting stuff like PID, while I plan to use this as a trading system, and need all the attributes to be saved
 
Oh my god, I love you. I found the problem was when I overwrote the file. Taking that out fixed it. (Kind of, crashed on opening the party screen but this was what was bothering me.)

That's why I told you to fix the "status" and "statusCount" variables.
Also, the input for the "mail" variable needs to be a form of "PokemonMail" otherwise it will also crash when looking at the Summary.

And I didn't just use the Mystery Gift functions because the one that comes with Essentials BW is limited and effectively creates a new pokemon with new stats, because of not setting stuff like PID, while I plan to use this as a trading system, and need all the attributes to be saved

Well, you could use these functions instead:

Code:
def pbPokemonToString(gift)
  ret=[Zlib::Deflate.deflate(Marshal.dump(gift))].pack("m")
  return ret
end

def pbStringToPokemon(gift)
  return [] if gift==""
  ret=Marshal.restore(Zlib::Inflate.inflate(gift.unpack("m")[0]))
  return ret
end

Which is basically found in the core Pokemon Essentials' Mystery Gift functions. (But renamed to be more appropriate in your case)

And by chance this will also fix all your other issues, while making it more easy on your part if you happen to change the structure of the PokeBattle_Pokemon class.
 
Back
Top