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

[Error] Why is my "Pocket Sand" script causing crashes at startup, and why is the error reporter stuck in a loop of "Swap } and ). And again. And again."?

  • 428
    Posts
    5
    Years
    Why is my "Pocket Sand" script causing crashes at startup, and why is the error reporter stuck in a loop of "Swap } and ). And again. And again."?

    Every error message I get tells me the engine doesn't like the placement of } or ), but switching them around and adding extra )s and }s does nothing to make the engine happy with my code. I just get an unhelpful error message that tells me nothing about what's actually wrong with code that seems fine.

    Code:
    Battle::ItemEffects::OnSwitchIn.add(:POCKETSAND,
      proc { |item, battler, battle|
        battle.pbDisplay(_INTL("{1} threw Pocket Sand!",
        battle.pbStartWeatherAbility(:Sandstorm, battler)
      }
    )

    When a Pokemon is switched in while holding this item, it should cause a Sandstorm.

    My "Caltrops" held item works just fine. Switch in a Pokemon holding Caltrops, and he scatters a layer of Spikes onto the foe's side of the field.

    You can have this working code and do whatever you want with it.
    Code:
    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))
      }
    )
     
    Thank you, that code looks right. But I still get this error message every time I get into a battle, no matter what NPC I am battling.

    Code:
    [Pokémon Essentials version 20.1]
    [v20.1 Hotfixes 1.0.2]
    
    Script error in event 5 (coords 27,4), map 3 (Aaa's house)
    Exception: NameError
    Message: wrong constant name Battle::Move::
    
    ***Full script:
    TrainerBattle.start(:LEADER_Brock, "Brock")
    Backtrace:
    172:Battle_Move:58:in `const_defined?'
    172:Battle_Move:58:in `from_pokemon_move'
    161:Battler_Initialize:89:in `block in pbInitPokemon'
    161:Battler_Initialize:88:in `each'
    161:Battler_Initialize:88:in `each_with_index'
    161:Battler_Initialize:88:in `pbInitPokemon'
    267:ShadowPokemon_Other:196:in `pbInitPokemon'
    161:Battler_Initialize:61:in `pbInitialize'
    148:Battle_StartAndEnd:117:in `pbCreateBattler'
    148:Battle_StartAndEnd:153:in `block (3 levels) in pbSetUpSides'

    What am I doing wrong?
     
    Back
    Top