v18 Possible Error in "pbMessageOnRecall"

This thread pertains to v18 of Pokémon Essentials.

Hollow_Ego

Cooltrainer
Member
Joined
May 19, 2018
Posts
103
I'm working on a battle related script and got an error within
Ruby:
pbMessageOnRecall
So I checked a clean copy of Essentials annd reproduced the error there as well.

The error message (shortened):
Ruby:
Message: undefined local variable or method `b' for #<PokeBattle_Battle:0x11aced68>
Backtrace: Battle_Action_Switching:248:in `pbMessageOnRecall'

The clean code within v18.1 (line 248 corresponds to line 15 here):
Ruby:
def pbMessageOnRecall(battler)
    if battler.pbOwnedByPlayer?
      if battler.hp<=battler.totalhp/4
        pbDisplayBrief(_INTL("Good job, {1}! Come back!",battler.name))
      elsif battler.hp<=battler.totalhp/2
        pbDisplayBrief(_INTL("OK, {1}! Come back!",battler.name))
      elsif battler.turnCount>=5
        pbDisplayBrief(_INTL("{1}, that’s enough! Come back!",battler.name))
      elsif battler.turnCount>=2
        pbDisplayBrief(_INTL("{1}, come back!",battler.name))
      else
        pbDisplayBrief(_INTL("{1}, switch out! Come back!",battler.name))
      end
    else
      owner = pbGetOwnerName(b.index)
      pbDisplayBrief(_INTL("{1} withdrew {2}!",owner,battler.name))
    end
  end

I think b.index should be battler.index
At least it works for me.
 

ThatWelshOne_

Eevee User
Member
Joined
Sep 29, 2020
Posts
140
I believe this was fixed in a recent Github commit. Looking at the changes on Github, it looks like you're right: changing owner = pbGetOwnerName(b.index) to owner = pbGetOwnerName(battler.index) fixes the error.
 
Top