Zekko
Seen 9 Hours Ago
Posted 2 Days Ago
340 posts
2.5 Years
Battle::ItemEffects::OnSwitchIn.add(:CALTROPS,
  proc { |item, user, battler, target, move, battle|
  next    if user.pbOpposingSide.effects[PBEffects::Spikes] >= 3
      user.pbOpposingSide.effects[PBEffects::Spikes] += 1
    battler.pbConsumeItem
  }
)
Battle::ItemEffects::OnSwitchIn.add(:CALTROPS,
  proc { |item, battler, battle|
  next    if user.pbOpposingSide.effects[PBEffects::Spikes] >= 3
      user.pbOpposingSide.effects[PBEffects::Spikes] += 1
    battle.pbDisplay(_INTL("{1} scatters Caltrops on the foe's side of the field!",
       battler.pbThis, battler.itemName))
  }
)
Which version of this code is closer to correct, and what will fix it?

The goal is for the held item to use Spikes once, and then consume itself, when the Pokemon holding it is sent out.

Sometimes the error message claims the engine doesn't know what "User" or "Battle" or "Battler" is, and sometimes it claims to not know what "pbOpposingSide" or "PBEffects::Spikes" is.

Vendily

Seen 1 Hour Ago
Posted 4 Days Ago
The OnSwitchIn Item Effect proc only takes 3 arguments
Battle::ItemEffects::OnSwitchIn.add(:CALTROPS,
  proc { |item, battler, battle|
    next if battler.pbOpposingSide.effects[PBEffects::Spikes] >= 3
    battler.pbOpposingSide.effects[PBEffects::Spikes] += 1
    battle.pbDisplay(_INTL("{1} scatters {2} all around {3}'s feet!",
       battler.pbThis, battler.itemName, battler.pbOpposingTeam(true)))
    battler.pbConsumeItem
  }
)