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

[Scripting Question] [RESOLVED] Pulling Species number from a file (Essentials BW 3.1.1)

1,682
Posts
8
Years
    • Seen yesterday
    [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:
    1,748
    Posts
    14
    Years
  • 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:
    1,682
    Posts
    8
    Years
    • Seen yesterday
    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
     
    1,748
    Posts
    14
    Years
  • 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?
     
    1,682
    Posts
    8
    Years
    • Seen yesterday
    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
     
    1,748
    Posts
    14
    Years
  • 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