• 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!
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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] Disable Key Item in certain Map/Area

  • 15
    Posts
    6
    Years
    • Seen Mar 15, 2025
    Hello Community,

    I recently added a key item to the game that allows the player to change their clothes. I now want to restrict the usage of it but only in certain maps (for example dont allow the player to change their outfit while inside a rocket hideout) - is there a way to add this? As of now I only see a flag for terrain, and I dont know how to really apply that to my idea.

    so, is there a way to limit the use of a key item on certain maps? A switch placed on the ground that works as a toggle would probably also work too, but then I would need to know what this switch needs to do.

    Thanks for the help!
     
    You can check $game_map.map_id inside the key item's effect. e.g. if you only wanted to allow the item on maps 2, 3, and 5:
    Code:
    ItemHandlers::UseInField.add(:ITEM,proc{|item|
      if [2,3,5].include?($game_map.map_id)
        # Your effect code goes here.
      end
    })
    (Note, I'm not sure what map IDs actually look like, maybe they're not numbers?)
     
    Last edited:
    You can check $game_map.map_id inside the key item's effect. e.g. if you only wanted to allow the item on maps 2, 3, and 5:
    Code:
    ItemHandlers::UseInField.add(:ITEM,proc{|item|
      if [2,3,5].include?($game_map.map_id)
        # Your effect code goes here.
      end
    })
    (Note, I'm not sure what map IDs actually look like, maybe they're not numbers?)

    Thanks a ton mgriffin! This helpt me a lot. I slightly modified that code, to work as an exclude mechanism instead an including one. Modified script looks as follows:

    ItemHandlers::UseInField.add(:ITEM,proc{|item|
    if [2,3,5].include?($game_map.map_id)
    else
    # Your effect code goes here.
    end
    })

    That way it does nothing, when you are on one of the included maps (which results in the default "cant use this here" message), and executes normally on every other!
    Map ID can be found under Map Properties, when rightclicking a selected Map
     
    Last edited:
    Just so you know, you could have also made excluding work by using
    Code:
    if ![2,3,5].include?($game_map.map_id)
      # ...
    end
    Instead of an empty if and putting the code in the else, the ! means "not".
     
    Last edited:
    Back
    Top