• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • 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:
    Back
    Top