• 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] Error when "itemizing" Flash

IvyMe

My Twitter: @_IvyMe
11
Posts
6
Years
  • I am trying to convert HM Flash to an item, but when I use them I have this error:
    Code:
    Excepción: NameError
    Mensaje: uninitialized constant UseMoveFlash
    PItem_ItemEffects:1755
    PItem_ItemEffects:1754:in `call'
    Event:150:in `trigger'
    PItem_Items:219:in `triggerUseInField'
    PItem_Items:499:in `pbUseKeyItemInField'
    PScreen_PauseMenu:198:in `pbStartPokemonMenu'
    PScreen_PauseMenu:143:in `loop'
    PScreen_PauseMenu:269:in `pbStartPokemonMenu'
    Scene_Map:193:in `call_menu'
    Scene_Map:163:in `update'

    I revised all, I have this code in PField_HiddenMoves:
    Code:
    #===============================================================================
    # Destello  /  Flash
    #===============================================================================
    HiddenMoveHandlers::CanUseMove.add(:FLASH,proc{|move,pkmn|
      if !$DEBUG &&
       !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORFLASH])
       Kernel.pbMessage(_INTL("Necesitas una nueva medalla."))
       return false
      end
      if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
       Kernel.pbMessage(_INTL("No puedes usar eso aquí."))
       return false
      end
      if $PokemonGlobal.flashUsed
       Kernel.pbMessage(_INTL("Ya se está utilizando."))
       return false
      end
       return true
    })
    
    HiddenMoveHandlers::UseMove.add(:FLASH,proc{|move,pokemon|
     darkness=$PokemonTemp.darknessSprite
     return false if !darkness || darkness.disposed?
      if !pbHiddenMoveAnimation(nil)
       Kernel.pbMessage(_INTL("¡{1} usó {2}!",pokemon.name,PBMoves.getName(move)))
     end
      $PokemonGlobal.flashUsed=true
      while darkness.radius<176
       Graphics.update
       Input.update
       pbUpdateSceneMap
       darkness.radius+=4
      end
     return true
    })
    
    def CanUseMoveFlash?
      if !$DEBUG &&
       !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORFLASH])
       Kernel.pbMessage(_INTL("Necesitas una nueva medalla."))
       return false
      end
      if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
       Kernel.pbMessage(_INTL("No puedes usar eso aquí."))
       return false
      end
      if $PokemonGlobal.flashUsed
       Kernel.pbMessage(_INTL("Ya se está utilizando."))
       return false
      end
       return true
    end
    
    def UseMoveFlash
     darkness=$PokemonTemp.darknessSprite
     return false if !darkness || darkness.disposed?
      if !pbHiddenMoveAnimation(nil)
       Kernel.pbMessage(_INTL("¡{1} usó el Casco Minero!"))#,$Trainer.name))
     end
      $PokemonGlobal.flashUsed=true
      while darkness.radius<176
       Graphics.update
       Input.update
       pbUpdateSceneMap
       darkness.radius+=4
      end
     return true
    end

    And I have that at the bottom of PItem_ItemEffects:
    Code:
    ItemHandlers::UseFromBag.add(:MININGHELMET,proc{|item|
       next CanUseMoveFlash? ? 2 : 0
    })
    
    ItemHandlers::UseInField.add(:MININGHELMET,proc{|item|
      UseMoveFlash if CanUseMoveFlash?
    })

    And in PBS:

    Code:
    676,MININGHELMET,Casco Minero, Cascos Mineros,8,0,"Un casco que puede iluminar cuevas muy oscuras.",2,0,6,

    I follow the -FL- tutorial on the wiki to make that, but I can't find the error. I don't understood 100% the tutorial, maybe it's a bit difficult for me, but I think that I have all in order.
     
    220
    Posts
    13
    Years
    • Seen Nov 29, 2021
    I'm not sure, but I think "return true" in UseMoveFlash is causing you the issue. Remove it. (You're telling it to send a value to the function that called it, but the function that calls it doesn't assign a variable for that valye.)
     

    IvyMe

    My Twitter: @_IvyMe
    11
    Posts
    6
    Years
  • I'm not sure, but I think "return true" in UseMoveFlash is causing you the issue. Remove it. (You're telling it to send a value to the function that called it, but the function that calls it doesn't assign a variable for that valye.)
    I tried that, but nothing. I ultra simplified the code:
    Code:
    def UseMoveFlash
      Kernel.pbMessage(_INTL("?Jugador us? el Casco Minero!"))
    end
    But shows me the same error. The problem should it be in another part but I can know where could it be
     
    Back
    Top