v19.1 Script Stopped Working

This thread pertains to v19.1 of Pokémon Essentials.

Pokemon Liberator

Cooltrainer
Member
Joined
Jul 18, 2021
Posts
140
Age
41
Hi all, I have a few new scripts I have made and successfully ran multiple times. However, after making the second script, it seemed to mess up the first script. They both used pbChooseAblePokemon at the time, and it seemed to be the cause of the error when I looked at the backtrace log. I also started to receive the wrong number of argument errors. My goal is for both scripts to be usable in my game. Both scripts are used for separate events that, for playtesting purposes, are currently on the same map.

The first script is for my Pokemon Broker event. It calculates the value of the chosen pokemon using pbChooseAblePokemon and allows the player to sell that pokemon if they want. The script allows two different script commands. The first allows any pokemon type to be sold 'sellPokemonToNPC' and the second 'sellPokemonToNPC(:WATER)' allows the Pokemon Broker event to specify a specific pokemon type, and the player may only select and sell the specified type of pokemon.

The second script is for a custom mechanic called Primal Boost, which is similar to Hyper Training and requires level 100, except it raises IV's and lowers the selected pokemon's level. Primal Boost also calls its own scene from a separate script when it is performed. These are the script commands for the event I am using. 'primal_boost = PokemonPrimalBoost.new' and 'primal_boost.primal_boost_pokemon'

When I wrote these scripts, they both playtested fine. It was when I attempted to sell a primal boosted pokemon that I received an error related to 'pbChoosePokemon', and so I began restructuring both scripts along with altering both events so that both mechanics could coexist. This was a long, confusing process that I have worked on for several days now. I have rewritten the scripts so many times! However, I had the common sense to save both the working scripts in Notepad before changing them so many times. I wish I would have done something similar (sceenshots) for the event layouts. Anyway, all my modifications only led to more error messages, and I have reverted everything back to normal, or at least as far back to working as possible. I thought I would ask for some help and see if anyone has some insight.

Some of my modifications included trying to use pbChooseAblePokemon in the events and even creating separate methods in the UI_Party. I tried not to use pbChoosePokemon but found that it is used when the party screen is called. I had a miserable attempt at trying to create a copy of the party screen too. Maybe I have been wrong about pbChoosePokemon, but that is why I am here now. I will post both scripts below and attach the current error messages and event screenshots. Currently, my Pokemon Broker event has an error, but the line of script in the conditional branch looks correct to me, and I couldn't find anything online or on the Wiki. Please note that I am using v19.1, so it's $trainer, not $player.

Pokemon Broker:
def pbChooseAblePokemon(type = nil)
  return pbChoosePokemon(1, 3, proc { |pkmn|
    next false if pkmn.isEgg?
    next true if type.nil?  # Allow all Pokémon if type is not specified
    next pkmn.hasType?(type)
  })
end

def sellPokemonToNPC(pokemon_type = nil)
  eligible_pokemon = $Trainer.party.select do |pkmn|
    if pokemon_type
      pkmn.hasType?(pokemon_type)
    else
      true
    end
  end

  if eligible_pokemon.empty?
    Kernel.pbMessage(_INTL("You have no Pokémon that can be sold."))
    return
  end

  pbChooseAblePokemon(pokemon_type)
  chosen_index = pbGet(1)

  if chosen_index == -1
    return
  end

  chosen_pokemon = $Trainer.party[chosen_index]

  total_stats = chosen_pokemon.baseStats[:HP] +
                chosen_pokemon.baseStats[:ATTACK] +
                chosen_pokemon.baseStats[:DEFENSE] +
                chosen_pokemon.baseStats[:SPECIAL_ATTACK] +
                chosen_pokemon.baseStats[:SPECIAL_DEFENSE] +
                chosen_pokemon.baseStats[:SPEED]

  species_data = GameData::Species.get(chosen_pokemon.species)
  catch_rate = species_data.catch_rate

  base_price = total_stats - (catch_rate * 1) + (chosen_pokemon.level * 2)

  multiplier = 1

  base_price *= 2 if chosen_pokemon.shiny?
  base_price *= 2 if chosen_pokemon.ot == "Alpha"

  pokeball_price = (GameData::Item.get(species_data.egg_groups[0].to_sym).price rescue 0)
  if pokeball_price > 0
    base_price += pokeball_price
  end

  base_price += ((GameData::Item.get(chosen_pokemon.item).price rescue 0) / 2) if chosen_pokemon.item

  if Kernel.pbConfirmMessage(_INTL("Would you like to sell your {1} for ${2}?", chosen_pokemon.name, base_price))
    $Trainer.party.delete_at(chosen_index)
    $Trainer.money += base_price
    Kernel.pbMessage(_INTL("You sold your {1} for ${2}.", chosen_pokemon.name, base_price))
  else
    Kernel.pbMessage("You declined the sale.")
  end
end


# Script Commands:
#sellPokemonToNPC - Will allow selling of any type.
#sellPokemonToNPC(:WATER) - Will allow selling only Water-type Pokémon.

Primal Boost:
################################################################################
# Primal Boost
################################################################################

def pbChooseAblePokemon
  return pbChoosePokemon(1, 3, proc { |pkmn|
    next false if pkmn.isEgg?
    next pkmn.level >= 100
  })
end

class PokemonPrimalBoost
  def initialize
    @pokemon = nil
  end

  def valid_pokemon?(pokemon)
    return true if pokemon.iv.values.any? { |iv| iv < 31 }
    false
  end

  def choose_pokemon
    pbChooseAblePokemon { |pkmn|
      pkmn.level == 100
    }

    chosen_pokemon_index = pbGet(1)

    return if chosen_pokemon_index == -1

    @pokemon = $Trainer.party[chosen_pokemon_index]
  end

  def primal_boost_pokemon
    choose_pokemon

    return unless @pokemon

    return unless valid_pokemon?(@pokemon)

    increase_all_ivs_by_11(@pokemon)
    reduce_level_and_experience_by_10(@pokemon)

    @pokemon.calc_stats
    
    # Call the original PokemonPrimalBoostScene here
    scene = PokemonPrimalBoostScene.new
    scene.pbStartScene(@pokemon)
    scene.pbPrimalBoost
    scene.pbEndScene

    pbMessage(_INTL("{1} has been Primal Boosted!", @pokemon.name))
  end

  def increase_all_ivs_by_11(pokemon)
    stats = [:HP, :ATTACK, :DEFENSE, :SPECIAL_ATTACK, :SPECIAL_DEFENSE, :SPEED]
    
    stats.each do |stat|
      current_iv = pokemon.iv[stat]
      next if current_iv.nil?
      
      # Increase the IV
      pokemon.iv[stat] = [current_iv + 11, 31].min
    end
  end

  def reduce_level_and_experience_by_10(pokemon)
    new_level = [pokemon.level - 10, 1].max # Ensure level doesn't go below 1
    pokemon.level = new_level
    pokemon.exp = pokemon.growth_rate.minimum_exp_for_level(new_level)
  end
end

If anyone decides to look at all this information, thank you for your time and effort! I will keep trying to get both scripts to function. Also, if the Primal Boost scene is needed, I can post that script as well. I will be watching this thread. These scripts are some of the last to complete my game.
 

Attachments

  • Pokemon Broker Error.png
    Pokemon Broker Error.png
    21.4 KB · Views: 13
  • Pokemon Broker Event page 1.png
    Pokemon Broker Event page 1.png
    24.3 KB · Views: 11
  • Pokemon Broker Event Page 2.png
    Pokemon Broker Event Page 2.png
    30.2 KB · Views: 9
  • Primal Boost Error.png
    Primal Boost Error.png
    17.3 KB · Views: 9
  • Primal Boost Event.png
    Primal Boost Event.png
    31.5 KB · Views: 12
Solution
I just wanted to let everyone know the issue was solved. It seems I accidentally deleted the following script:

pbChooseAblePokemon:
  def pbChooseAblePokemon(ableProc, allowIneligible = false)
    annot = []
    eligibility = []
    @party.each do |pkmn|
      elig = ableProc.call(pkmn)
      eligibility.push(elig)
      annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE"))
    end
    ret = -1
    @scene.pbStartScene(
      @party,
      (@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."),
      annot
    )
    loop do
      @scene.pbSetHelpText(
        (@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")
      )
      pkmnid = @scene.pbChoosePokemon
      break if pkmnid < 0...

wrigty12

Tester-Coder Hybrid
Member
Joined
Jul 24, 2022
Posts
182
Age
29
I'd recommend instead of overwriting pbChooseAblePokemon, since right now you're overwriting them in a way that will never be compatible with each other, you just copy the function and make a new one that does what you want but has a different name, and call the new function where you want it.

For example, pbChooseAblePokemonOfType and pbChooseAblePokemonPrimal
 

drdoom76

Cooltrainer
Member
Joined
Aug 1, 2023
Posts
114
Age
35
I second Wrigty. It looks like you're calling the same method from outside the script, with different settings. If that is the case, it would probably be easiest to just change the chooseablepokemon name.
 

Pokemon Liberator

Cooltrainer
Member
Joined
Jul 18, 2021
Posts
140
Age
41
@wrigty12 Thanks for the reply. I have tried writing separate methods for both scripts to work around 'pbChooseAblePokemon' and 'pbChoosePokemon' but I still ran into issues with both scripts. Maybe the methods I came up with were faulty in some way. I am not opposed to trying again, though.
@drdoom76 Thanks for the reply and input.

Here is the Pokemon Broker script updated with the new method:
Pokemon Broker (pbChooseAblePokemonByType):
################################################################################
# Pokemon Broker
################################################################################

def pbChooseAblePokemonByType(variableNumber, nameVarNumber, type = nil)
  pbChoosePokemon(variableNumber, nameVarNumber, proc { |pkmn|
    next false if pkmn.isEgg?
    next true if type.nil?  # Allow all Pokémon if type is not specified
    next pkmn.hasType?(type)
  })
end

def sellPokemonToNPC(pokemon_type = nil)
  eligible_pokemon = $Trainer.party.select do |pkmn|
    if pokemon_type
      pkmn.hasType?(pokemon_type)
    else
      true
    end
  end

  if eligible_pokemon.empty?
    Kernel.pbMessage(_INTL("You have no Pokémon that can be sold."))
    return
  end

  pbChooseAblePokemonByType(1, 3, pokemon_type)
  chosen_index = pbGet(1)

  if chosen_index == -1
    return
  end

  chosen_pokemon = $Trainer.party[chosen_index]

  total_stats = chosen_pokemon.baseStats[:HP] +
                chosen_pokemon.baseStats[:ATTACK] +
                chosen_pokemon.baseStats[:DEFENSE] +
                chosen_pokemon.baseStats[:SPECIAL_ATTACK] +
                chosen_pokemon.baseStats[:SPECIAL_DEFENSE] +
                chosen_pokemon.baseStats[:SPEED]

  species_data = GameData::Species.get(chosen_pokemon.species)
  catch_rate = species_data.catch_rate

  base_price = total_stats - (catch_rate * 1) + (chosen_pokemon.level * 2)

  multiplier = 1

  base_price *= 2 if chosen_pokemon.shiny?
  base_price *= 2 if chosen_pokemon.ot == "Alpha"

  pokeball_price = (GameData::Item.get(species_data.egg_groups[0].to_sym).price rescue 0)
  if pokeball_price > 0
    base_price += pokeball_price
  end

  base_price += ((GameData::Item.get(chosen_pokemon.item).price rescue 0) / 2) if chosen_pokemon.item

  if Kernel.pbConfirmMessage(_INTL("Would you like to sell your {1} for ${2}?", chosen_pokemon.name, base_price))
    $Trainer.party.delete_at(chosen_index)
    $Trainer.money += base_price
    Kernel.pbMessage(_INTL("You sold your {1} for ${2}.", chosen_pokemon.name, base_price))
  else
    Kernel.pbMessage("Player declined the sale.")
  end
end

# Script Command:
# sellPokemonToNPC - Will allow selling of any type.
# sellPokemonToNPC(:WATER) - Will allow selling only Water-type Pokémon.
# sellPokemonToNPC(:FOSSIL) - Will allow selling only Fossil-type Pokémon.

Here is the Primal Boost script updated with its new method:
Primal Boost (pbChooseAblePrimalBoostPokemon):
################################################################################
# pbChooseAblePrimalBoostPokemon Method
################################################################################

def pbChooseAblePrimalBoostPokemon
  return pbChooseAblePokemon(1, 3, proc { |pkmn|
    next false if pkmn.isEgg?
    next pkmn.level >= 100
  })
end

################################################################################
# Primal Boost
################################################################################

# Custom method for choosing eligible Pokémon for Primal Boost
def pbChooseAblePrimalBoostPokemon
  return pbChoosePokemon(1, 3, proc { |pkmn|
    next false if pkmn.isEgg?
    next pkmn.level >= 100
  })
end

class PokemonPrimalBoost
  def initialize
    @pokemon = nil
  end

  def valid_pokemon?(pokemon)
    return true if pokemon.iv.values.any? { |iv| iv < 31 }
    false
  end

  def choose_pokemon
    pbChooseAblePrimalBoostPokemon { |pkmn|  # Use the custom method here
      pkmn.level == 100
    }

    chosen_pokemon_index = pbGet(1)

    return if chosen_pokemon_index == -1

    @pokemon = $Trainer.party[chosen_pokemon_index]
  end

  def primal_boost_pokemon
    choose_pokemon

    return unless @pokemon

    return unless valid_pokemon?(@pokemon)

    increase_all_ivs_by_11(@pokemon)
    reduce_level_and_experience_by_10(@pokemon)

    @pokemon.calc_stats
    
    # Call the original PokemonPrimalBoostScene here
    scene = PokemonPrimalBoostScene.new
    scene.pbStartScene(@pokemon)
    scene.pbPrimalBoost
    scene.pbEndScene

    pbMessage(_INTL("{1} has been Primal Boosted!", @pokemon.name))
  end

  def increase_all_ivs_by_11(pokemon)
    stats = [:HP, :ATTACK, :DEFENSE, :SPECIAL_ATTACK, :SPECIAL_DEFENSE, :SPEED]
    
    stats.each do |stat|
      current_iv = pokemon.iv[stat]
      next if current_iv.nil?
      
      # Increase the IV
      pokemon.iv[stat] = [current_iv + 11, 31].min
    end
  end

  def reduce_level_and_experience_by_10(pokemon)
    new_level = [pokemon.level - 10, 1].max # Ensure level doesn't go below 1
    pokemon.level = new_level
    pokemon.exp = pokemon.growth_rate.minimum_exp_for_level(new_level)
  end
end

#Script Commands:
#pbChooseAblePrimalBoostPokemon  #Allows the selection of a level 100 pokemon
#PokemonPrimalBoost.new.primal_boost_pokemon  #Initiates the Primal Boost process for the selected Pokémon

So after playtesting both events, I still have an error pertaining to the Pokemon Broker event, where I use a conditional branch check to make sure the party has more than one pokemon. I still need to sort the reason for that error. I included it below, along with a new error for the Primal Boost script. Any further insight or help is appreciated.
 

Attachments

  • Pokemon Broker Event Error.png
    Pokemon Broker Event Error.png
    21.4 KB · Views: 12
  • Updated Primal Boost Error.png
    Updated Primal Boost Error.png
    30.9 KB · Views: 12

wrigty12

Tester-Coder Hybrid
Member
Joined
Jul 24, 2022
Posts
182
Age
29
Are you putting "if $Trainer.ablePokemonCount==1" in the script field of the conditional branch? Don't include "if" there, that may be what's causing the first error (hard to tell without actually seeing your event)

The second error is happening because pbChoosePokemon is getting passed more arguments that it is supposed to get at line 846 in the UI_Party script. I don't use 19.1, but basing it off of 20.1, I'm guessing that function is class PokemonPartyScreen > def pbChoosePokemon(helptext = nil). Did you edit line 846 to send more args or something?
 

drdoom76

Cooltrainer
Member
Joined
Aug 1, 2023
Posts
114
Age
35
@wrigty12 Thanks for the reply. I have tried writing separate methods for both scripts to work around 'pbChooseAblePokemon' and 'pbChoosePokemon' but I still ran into issues with both scripts. Maybe the methods I came up with were faulty in some way. I am not opposed to trying again, though.
@drdoom76 Thanks for the reply and input.

Here is the Pokemon Broker script updated with the new method:
Pokemon Broker (pbChooseAblePokemonByType):
################################################################################
# Pokemon Broker
################################################################################

def pbChooseAblePokemonByType(variableNumber, nameVarNumber, type = nil)
  pbChoosePokemon(variableNumber, nameVarNumber, proc { |pkmn|
    next false if pkmn.isEgg?
    next true if type.nil?  # Allow all Pokémon if type is not specified
    next pkmn.hasType?(type)
  })
end

def sellPokemonToNPC(pokemon_type = nil)
  eligible_pokemon = $Trainer.party.select do |pkmn|
    if pokemon_type
      pkmn.hasType?(pokemon_type)
    else
      true
    end
  end

  if eligible_pokemon.empty?
    Kernel.pbMessage(_INTL("You have no Pokémon that can be sold."))
    return
  end

  pbChooseAblePokemonByType(1, 3, pokemon_type)
  chosen_index = pbGet(1)

  if chosen_index == -1
    return
  end

  chosen_pokemon = $Trainer.party[chosen_index]

  total_stats = chosen_pokemon.baseStats[:HP] +
                chosen_pokemon.baseStats[:ATTACK] +
                chosen_pokemon.baseStats[:DEFENSE] +
                chosen_pokemon.baseStats[:SPECIAL_ATTACK] +
                chosen_pokemon.baseStats[:SPECIAL_DEFENSE] +
                chosen_pokemon.baseStats[:SPEED]

  species_data = GameData::Species.get(chosen_pokemon.species)
  catch_rate = species_data.catch_rate

  base_price = total_stats - (catch_rate * 1) + (chosen_pokemon.level * 2)

  multiplier = 1

  base_price *= 2 if chosen_pokemon.shiny?
  base_price *= 2 if chosen_pokemon.ot == "Alpha"

  pokeball_price = (GameData::Item.get(species_data.egg_groups[0].to_sym).price rescue 0)
  if pokeball_price > 0
    base_price += pokeball_price
  end

  base_price += ((GameData::Item.get(chosen_pokemon.item).price rescue 0) / 2) if chosen_pokemon.item

  if Kernel.pbConfirmMessage(_INTL("Would you like to sell your {1} for ${2}?", chosen_pokemon.name, base_price))
    $Trainer.party.delete_at(chosen_index)
    $Trainer.money += base_price
    Kernel.pbMessage(_INTL("You sold your {1} for ${2}.", chosen_pokemon.name, base_price))
  else
    Kernel.pbMessage("Player declined the sale.")
  end
end

# Script Command:
# sellPokemonToNPC - Will allow selling of any type.
# sellPokemonToNPC(:WATER) - Will allow selling only Water-type Pokémon.
# sellPokemonToNPC(:FOSSIL) - Will allow selling only Fossil-type Pokémon.

Here is the Primal Boost script updated with its new method:
Primal Boost (pbChooseAblePrimalBoostPokemon):
################################################################################
# pbChooseAblePrimalBoostPokemon Method
################################################################################

def pbChooseAblePrimalBoostPokemon
  return pbChooseAblePokemon(1, 3, proc { |pkmn|
    next false if pkmn.isEgg?
    next pkmn.level >= 100
  })
end

################################################################################
# Primal Boost
################################################################################

# Custom method for choosing eligible Pokémon for Primal Boost
def pbChooseAblePrimalBoostPokemon
  return pbChoosePokemon(1, 3, proc { |pkmn|
    next false if pkmn.isEgg?
    next pkmn.level >= 100
  })
end

class PokemonPrimalBoost
  def initialize
    @pokemon = nil
  end

  def valid_pokemon?(pokemon)
    return true if pokemon.iv.values.any? { |iv| iv < 31 }
    false
  end

  def choose_pokemon
    pbChooseAblePrimalBoostPokemon { |pkmn|  # Use the custom method here
      pkmn.level == 100
    }

    chosen_pokemon_index = pbGet(1)

    return if chosen_pokemon_index == -1

    @pokemon = $Trainer.party[chosen_pokemon_index]
  end

  def primal_boost_pokemon
    choose_pokemon

    return unless @pokemon

    return unless valid_pokemon?(@pokemon)

    increase_all_ivs_by_11(@pokemon)
    reduce_level_and_experience_by_10(@pokemon)

    @pokemon.calc_stats
   
    # Call the original PokemonPrimalBoostScene here
    scene = PokemonPrimalBoostScene.new
    scene.pbStartScene(@pokemon)
    scene.pbPrimalBoost
    scene.pbEndScene

    pbMessage(_INTL("{1} has been Primal Boosted!", @pokemon.name))
  end

  def increase_all_ivs_by_11(pokemon)
    stats = [:HP, :ATTACK, :DEFENSE, :SPECIAL_ATTACK, :SPECIAL_DEFENSE, :SPEED]
   
    stats.each do |stat|
      current_iv = pokemon.iv[stat]
      next if current_iv.nil?
     
      # Increase the IV
      pokemon.iv[stat] = [current_iv + 11, 31].min
    end
  end

  def reduce_level_and_experience_by_10(pokemon)
    new_level = [pokemon.level - 10, 1].max # Ensure level doesn't go below 1
    pokemon.level = new_level
    pokemon.exp = pokemon.growth_rate.minimum_exp_for_level(new_level)
  end
end

#Script Commands:
#pbChooseAblePrimalBoostPokemon  #Allows the selection of a level 100 pokemon
#PokemonPrimalBoost.new.primal_boost_pokemon  #Initiates the Primal Boost process for the selected Pokémon

So after playtesting both events, I still have an error pertaining to the Pokemon Broker event, where I use a conditional branch check to make sure the party has more than one pokemon. I still need to sort the reason for that error. I included it below, along with a new error for the Primal Boost script. Any further insight or help is appreciated.
Since I'm back in front of my computer.. I'm not versed in V19, but in V20 it would look something like this..
I think this is what you're going for.. you don't need a proc pkmn, becuase the chooseablepokemon takes care of that for you.
Secondly, unless ChooseAblePokemon is different in V19, it should automaticly rule out fainted and eggs, so the next false is not required.
The line below should fix your arg error.
Ruby:
def pbChooseAblePrimalBoostPokemon
  return pbChooseAblePokemon(1, 3) do |pkmn|
    next false if pkmn.isEgg?
    next pkmn.level >= 100
  end
end
 

wrigty12

Tester-Coder Hybrid
Member
Joined
Jul 24, 2022
Posts
182
Age
29
Since I'm back in front of my computer.. I'm not versed in V19, but in V20 it would look something like this..
I think this is what you're going for.. you don't need a proc pkmn, becuase the chooseablepokemon takes care of that for you.
Secondly, unless ChooseAblePokemon is different in V19, it should automaticly rule out fainted and eggs, so the next false is not required.
The line below should fix your arg error.
Ruby:
def pbChooseAblePrimalBoostPokemon
  return pbChooseAblePokemon(1, 3) do |pkmn|
    next false if pkmn.isEgg?
    next pkmn.level >= 100
  end
end
Hm I think that goes down the wrong path here. I think they already have the correctly formatted function that uses pbChoosePokemon; pbChooseAblePokemon should not be used within their new functions if a proc is wanted to be used, which it is to make sure it's level 100.

@Pokemon Liberator, for some reason you have pbChooseAblePrimalBoostPokemon defined twice, one using pbChooseAblePokemon and the other using pbChoosePokemon. Luckily, you have the pbChoosePokemon one defined second, so it overwrites the first one.

What you have here...
Ruby:
def pbChooseAblePrimalBoostPokemon
  return pbChoosePokemon(1, 3, proc { |pkmn|
    next false if pkmn.isEgg?
    next pkmn.level >= 100
  })
end

... should be the correct way of handling this. I just tested with the pbChooseAblePrimalBoostPokemon command as it's written (except using pkmn.egg? instead for v20 since apparently that was changed) and it works as expected allowing me to only select Level 100 Pokemon. It needs to be investigated why line 846 in UI_Party is passing 3 arguments for what I assume is a either a screne.pbChoosePokemon or @scene.pbChoosePokemon call (and should likely have no arguments) as that still seems to be the problem here, no so much what you've included in your code you've sent us.
 

Pokemon Liberator

Cooltrainer
Member
Joined
Jul 18, 2021
Posts
140
Age
41
@wrigty12 I believe you are correct about removing the 'if' in my conditional branch of my event. The event has a screenshot attached to my first post, along with the errors.

@drdoom76 I was trying to work around pbChoosePokemon and its other functions because the scripts began to conflict with one another. I have even tried adding the 'pbChooseAblePokemon' into the events themselves, but it did not prevent the argument error.

I now receive the exact argument error I get from my Primal Boost script, which I had expected. I had this same problem all week, and that's why I put everything back to my original scripts before posting on the forums. I was hoping, with help, I wouldn't end up with the same problem. I will post my UI_Party script, or at least the section of code that is causing the error. I know the line is 846, which is the 'def pbChoosePokemon(helptext=nil)' Also, you both should know that I have not modified the lines that the backtrace is refrencing. Here is the UI_Party script. If you need more of it, let me know.

UI_Party (Pokémon party mechanics):
# Pokémon party mechanics
#===============================================================================
class PokemonPartyScreen
  attr_reader :scene
  attr_reader :party

  def initialize(scene,party)
    @scene = scene
    @party = party
  end

  def pbStartScene(helptext,_numBattlersOut,annotations=nil)
    @scene.pbStartScene(@party,helptext,annotations)
  end

  def pbChoosePokemon(helptext=nil)
    @scene.pbSetHelpText(helptext) if helptext
    return @scene.pbChoosePokemon
  end

  def pbPokemonGiveScreen(item)
    @scene.pbStartScene(@party,_INTL("Give to which Pokémon?"))
    pkmnid = @scene.pbChoosePokemon
    ret = false
    if pkmnid>=0
      ret = pbGiveItemToPokemon(item,@party[pkmnid],self,pkmnid)
    end
    pbRefreshSingle(pkmnid)
    @scene.pbEndScene
    return ret
  end

  def pbPokemonGiveMailScreen(mailIndex)
    @scene.pbStartScene(@party,_INTL("Give to which Pokémon?"))
    pkmnid = @scene.pbChoosePokemon
    if pkmnid>=0
      pkmn = @party[pkmnid]
      if pkmn.hasItem? || pkmn.mail
        pbDisplay(_INTL("This Pokémon is holding an item. It can't hold mail."))
      elsif pkmn.egg?
        pbDisplay(_INTL("Eggs can't hold mail."))
      else
        pbDisplay(_INTL("Mail was transferred from the Mailbox."))
        pkmn.mail = $PokemonGlobal.mailbox[mailIndex]
        pkmn.item = pkmn.mail.item
        $PokemonGlobal.mailbox.delete_at(mailIndex)
        pbRefreshSingle(pkmnid)
      end
    end
    @scene.pbEndScene
  end

  def pbEndScene
    @scene.pbEndScene
  end

  def pbUpdate
    @scene.update
  end

  def pbHardRefresh
    @scene.pbHardRefresh
  end

  def pbRefresh
    @scene.pbRefresh
  end

  def pbRefreshSingle(i)
    @scene.pbRefreshSingle(i)
  end

  def pbDisplay(text)
    @scene.pbDisplay(text)
  end

  def pbConfirm(text)
    return @scene.pbDisplayConfirm(text)
  end

  def pbShowCommands(helptext,commands,index=0)
    return @scene.pbShowCommands(helptext,commands,index)
  end

I do have a third script that is called by the Primal Boost script, which is a scene. I don't think that is the issue, but I can share that script as well if you want to rule it out as a possibility. So at this point, both scripts have the same error, which points to line 846 in UI_party.
 

Attachments

  • Pokemon Broker Update Error.png
    Pokemon Broker Update Error.png
    29.9 KB · Views: 9
Last edited:

wrigty12

Tester-Coder Hybrid
Member
Joined
Jul 24, 2022
Posts
182
Age
29
Have you gone through Backtrace line by line and found which command is passing 3 arguments? That's the issue. I don't think the issue is in what you've provided but it's hard to tell. Just posting a segment of UI_Party is tough, since the line numbers dont line up and there are multiple versions of "pbChoosePokemon", so it's confusing already to troubleshoot without the entire picture.
 

Pokemon Liberator

Cooltrainer
Member
Joined
Jul 18, 2021
Posts
140
Age
41
Have you gone through Backtrace line by line and found which command is passing 3 arguments? That's the issue. I don't think the issue is in what you've provided but it's hard to tell. Just posting a segment of UI_Party is tough, since the line numbers dont line up and there are multiple versions of "pbChoosePokemon", so it's confusing already to troubleshoot without the entire picture
What's the best way to go through the backtrace and find what is wrong?
 

wrigty12

Tester-Coder Hybrid
Member
Joined
Jul 24, 2022
Posts
182
Age
29
You're given each line that's called. You need to just go to each line that's listed.

In all honestly, if you're having trouble, an option could be uploading your entire project file somewhere as a zip and sending it my direction, and I could give it a shot trying to find the issue.
 

Pokemon Liberator

Cooltrainer
Member
Joined
Jul 18, 2021
Posts
140
Age
41
You're given each line that's called. You need to just go to each line that's listed.

In all honestly, if you're having trouble, an option could be uploading your entire project file somewhere as a zip and sending it my direction, and I could give it a shot trying to find the issue.
Just go to each line and look for anything that is passing 3 arguments? Give me a few minutes, I will take a look at each line.
 

Pokemon Liberator

Cooltrainer
Member
Joined
Jul 18, 2021
Posts
140
Age
41
You're given each line that's called. You need to just go to each line that's listed.

In all honestly, if you're having trouble, an option could be uploading your entire project file somewhere as a zip and sending it my direction, and I could give it a shot trying to find the issue.
I'm not seeing anything that has three arguments. If you don't mind taking a look, I will accept your offer, and share the project with you. This is my first project I have shared, so give me a minute to see if I can figure out how to share it.
 

Pokemon Liberator

Cooltrainer
Member
Joined
Jul 18, 2021
Posts
140
Age
41
This may take awhile...I was almost done using XP's default compression but aborted it. It's about 1/3 of the way finished, though.

@wrigty12 When I finally get the project uploaded to Google Drive should I just message you a shareable link to the project folder?
 
Last edited:

Pokemon Liberator

Cooltrainer
Member
Joined
Jul 18, 2021
Posts
140
Age
41
I just wanted to let everyone know the issue was solved. It seems I accidentally deleted the following script:

pbChooseAblePokemon:
  def pbChooseAblePokemon(ableProc, allowIneligible = false)
    annot = []
    eligibility = []
    @party.each do |pkmn|
      elig = ableProc.call(pkmn)
      eligibility.push(elig)
      annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE"))
    end
    ret = -1
    @scene.pbStartScene(
      @party,
      (@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."),
      annot
    )
    loop do
      @scene.pbSetHelpText(
        (@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")
      )
      pkmnid = @scene.pbChoosePokemon
      break if pkmnid < 0
      if !eligibility[pkmnid] && !allowIneligible
        pbDisplay(_INTL("This Pokémon can't be chosen."))
      else
        ret = pkmnid
        break
      end
    end
    @scene.pbEndScene
    return ret
  end

Special thanks to wrigty12 for helping me solve this so fast!
 
Solution
Top