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

Call a common event from the script section?

pokemonmasteraaron

The blind Pokémon Master!
323
Posts
13
Years
  • Hi there!
    I'm trying to call a common event when a key item is used. Unfortunately, the old way, he RMXP standard way, does not work in essentials. That was something like $game_temp.call_common_event(id), don't remember exactly. How can I do the equivalent i essentials?
    Thanks!
     

    pokemonmasteraaron

    The blind Pokémon Master!
    323
    Posts
    13
    Years
  • That works great, thanks! Is there a way to close the bag automatically though, before the common event happens? It glitches up if I do this with the bag still obviously open. I know the Old Rod, for example, closes the bag before fishing, but I don't see the code responsible for that exactly.
    Thanks,
    Aaron
     
    94
    Posts
    11
    Years
    • Seen May 4, 2018
    Hmm, I'm not sure. Is your Item called with the handler UseFromBag like this?

    Code:
    ItemHandlers::UseFromBag.add(:ITEM,proc{|item|
    [COLOR="SeaGreen"]#Item effect code (probably pbCommonEvent(id))[/COLOR]
         next [B][COLOR="Red"]2[/COLOR][/B]
       else
         Kernel.pbMessage(_INTL("Text"))
         next 0
       end
    })

    Cause according to the wiki, 2 or 4 should close the Bag:

    "For when the item is being used from the Bag, but not on a chosen Pokémon. Typically used for Escape Rope, Repels, all Key Items and a few others.
    Returns one of the following numbers:

    0 if the item was not used.
    1 - The item was used, and the Bag screen stays open.
    2 - The item was used, and the Bag screen is closed.
    3 - The item was used, and it was consumed.
    4 - The item was used, it was consumed, and the Bag screen is closed."

    If your item is consumed after use then the value in red should be 4
     
    35
    Posts
    8
    Years
    • Seen Jun 3, 2023
    Essential 17.2
    Like this:

    ItemHandlers::UseFromBag.add(:ITEM,proc{|item|
    next (pbCommonEvent(id)) ? 2 : 0
    })
     
    Back
    Top