Menu Is Closing *SOLVED*

Started by Seltzer Cole, December 02, 2013, 03:13:38 pm

Previous topic - Next topic

Seltzer Cole

December 02, 2013, 03:13:38 pm Last Edit: December 10, 2013, 06:49:16 pm by Seltzer Cole
.

When I go into my inventory and use an item, it uses it but automatically closes my inventory. How do I change this so that the inventory remains open until I decide to cancel out?

Quote from: gameus on May 06, 2013, 09:33:23 pm
Go into Scene_Item, line 71. Change this:
$scene = Scene_Menu.new(0)

to this
$scene = Scene_Map.new


Then to open the item menu through your events, use a Script Call:
$scene = Scene_Item.new



I am currently using the above method to call my inventory. Not sure if it is causing the issue or not but figured I would let you all know in case it is. Thanks.

.
You know you play video games to much when you put sunglasses on and whisper "Plus 10 Appearance"

If at first you don't succeed, call it version 1.0

KK20

Are you talking about items that call common events?

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

ForeverZer0

As KK20 has said, your item being used must have a common event it is calling when used, or you are using a custom menu system, in which case you would need to post the script up so someone can look at it.  The default system only closes the window if the item being used has a common event attached to its use.

If you simply want to do away with this happening, find the "update_target" method in Scene_Item, and find this section:
        # If common event ID is valid
        if @item.common_event_id > 0
          # Common event call reservation
          $game_temp.common_event_id = @item.common_event_id
          # Switch to map screen
          $scene = Scene_Map.new
          return
        end


Make it look like this:
        # If common event ID is valid
        if @item.common_event_id > 0
          # Common event call reservation
          $game_temp.common_event_id = @item.common_event_id
        end


Beware that this could cause issues depending on what common events are doing when an item is used.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Seltzer Cole

Quote from: ForeverZer0 on December 02, 2013, 07:26:24 pm


Yeah the item I am using is calling a common event to be used but it is closing the inventory screen. I am not using a menu script of any kind. I just have the main menu disabled and a parallel process that runs so when you open the menu it instead takes you to your inventory and not the main menu.

Apparently the common event thing is what is closing the menu. I doubt I will edit the Scene_Item anymore since I don't want issues happening lol.

Why does the game close your inventory if an item used calls a common event? That doesn't make sense. Why not keep it open?
You know you play video games to much when you put sunglasses on and whisper "Plus 10 Appearance"

If at first you don't succeed, call it version 1.0

Sase

@Seltzer Cole
Common events can do so much different things, like teleport the player to another map, cause some dialogue, move events around etc. so it's only logical this happens.

ForeverZer0

Making the edit will cause issues if your common events do things as Sase mentioned above.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Zexion

Have you tried adding a script call at the end of your common event? Just add $scene = Scene_Item.new

KK20

Not to mention, the only scenes that can execute a common event are Scene_Map and Scene_Battle. Zexion's solution is pretty much the closest thing you can get to what you want without causing errors.

if $scene.is_a?(Scene_Map)
$scene = Scene_Item.new
end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Seltzer Cole

Quote from: Zexion on December 03, 2013, 03:38:08 pm
Have you tried adding a script call at the end of your common event? Just add $scene = Scene_Item.new


I have the menu disabled as in my original post states. I have a parallel process in a common event that will open your inventory screen (not the main menu, just the inventory screen that displays your items) using $scene = Scene_Item.new.

My question was, why when I use for example, some item of any kind while the inventory screen is open, that is set to call upon a common event to do whatever purpose I have given it, my inventory screen will cancel out? Doesn't the inventory screen remain open at all times until you tell the game to cancel out? Why does it automatically do so and is there a way to fix that.

EDIT : Unless however, you meant add the script call in the common event that the item is calling o.o LIGHT BULB!!
You know you play video games to much when you put sunglasses on and whisper "Plus 10 Appearance"

If at first you don't succeed, call it version 1.0

ForeverZer0

It is supposed to close if the item calls a common event, this is the desired behavior.
Traditionally, normal menu-use items do not call common events, as it is usually reserved for "special" items and what-not, but as in your case, this isn't always true.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

KK20

It's almost like you ignored my post completely.
Quote from: KK20 on December 03, 2013, 04:23:16 pm
Not to mention, the only scenes that can execute a common event are Scene_Map and Scene_Battle.

If you were to stay in Scene_Item when using an item that calls a common event, it wouldn't do anything. And as F0 posted earlier:
Code: Scene_Item class

        # If common event ID is valid
        if @item.common_event_id > 0        #<======= Basically says if the item you selected calls a common event
          # Common event call reservation
          $game_temp.common_event_id = @item.common_event_id   #<=== Common event stored in memory so that when you return to Scene_Map, it will execute the common event
          # Switch to map screen
          $scene = Scene_Map.new  #<======= Effectively closes out of your Scene_Item
          return
        end

It's not just you. If we use an item to call upon a common event, we would get the exact same experience as you. This is not a bug. This is not a flaw. This is how it is supposed to work because doing it any other way would cause more problems.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Seltzer Cole

Quote from: KK20 on December 03, 2013, 11:57:04 pm
It's almost like you ignored my post completely.
Quote from: KK20 on December 03, 2013, 04:23:16 pm
Not to mention, the only scenes that can execute a common event are Scene_Map and Scene_Battle.

If you were to stay in Scene_Item when using an item that calls a common event, it wouldn't do anything. And as F0 posted earlier:
Code: Scene_Item class

        # If common event ID is valid
        if @item.common_event_id > 0        #<======= Basically says if the item you selected calls a common event
          # Common event call reservation
          $game_temp.common_event_id = @item.common_event_id   #<=== Common event stored in memory so that when you return to Scene_Map, it will execute the common event
          # Switch to map screen
          $scene = Scene_Map.new  #<======= Effectively closes out of your Scene_Item
          return
        end

It's not just you. If we use an item to call upon a common event, we would get the exact same experience as you. This is not a bug. This is not a flaw. This is how it is supposed to work because doing it any other way would cause more problems.


I never said it was a bug, just asked why it has to be like that. But I actually stuck in $scene = Scene_Item.new into the common event the item calls so the second your inventory closes, it opens right back up lmao. There is a slight second where you see the map but it works...kind of. I will probably end up making my own menu in the near future.
You know you play video games to much when you put sunglasses on and whisper "Plus 10 Appearance"

If at first you don't succeed, call it version 1.0

Zexion

You could just make the item play some kind of animation before returning to the menu. That would make it seem like it was supposed to do that all along lol
E.g.
ITEMS STUFF HERE
Play Animation
Wait x frames (equal to animation + 20ish)
scene_item

Seltzer Cole

Quote from: Zexion on December 05, 2013, 10:13:18 am
You could just make the item play some kind of animation before returning to the menu. That would make it seem like it was supposed to do that all along lol
E.g.
ITEMS STUFF HERE
Play Animation
Wait x frames (equal to animation + 20ish)
scene_item


Good idea. I will test this out. Some kind of item animation would definitely make it more appealing than a quick flash to the map and your inventory randomly reopening.  :)
You know you play video games to much when you put sunglasses on and whisper "Plus 10 Appearance"

If at first you don't succeed, call it version 1.0

ForeverZer0

What exactly does the common event do? 
I personally don't think the idea of the menu closing, playing an animation, and reopening sound appealing. Now this is simply my opinion, but I would be annoyed at such a thing happening when I used an item.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Seltzer Cole

December 08, 2013, 10:30:33 am #15 Last Edit: December 08, 2013, 10:32:15 am by Seltzer Cole
Quote from: ForeverZer0 on December 06, 2013, 04:58:17 pm
What exactly does the common event do?  
I personally don't think the idea of the menu closing, playing an animation, and reopening sound appealing. Now this is simply my opinion, but I would be annoyed at such a thing happening when I used an item.


I am not using the menu that comes with the game because I am eventing my own ABS game. The menu the game comes with is completely unecessary as it contains a ton of crap I will not be using. So I disabled it and have a parallel process where you can manually call your item menu and equip menu.   :^_^':

When you use an item, for example a healing item, it calls a common event to use so it can change the variable which is your HP. Basically any item you will be using will close the item menu lol. I can probably stop this by making my own custom menu which I have done before (tons of eventing...) but idk yet. The fact that all of you have pointed out, that the menu will not close during the map or battle scene, sucks for me. Even if I added in my own custom menu through events, such as 2 boxes on your screen which is keyed to X and Z for example, in order to stick items in those 2 slots you would still have to go to your inventory screen, which would close it out on you.

No matter what, when you use a healing item it calls your HP common event so I would need a way for the game to call upon that common event. Which means the item would have to call it, therefore closing the inventory menu.

Basically, I am shafted all ways unless I just stick someones script in my game, which I am trying to avoid atm.
You know you play video games to much when you put sunglasses on and whisper "Plus 10 Appearance"

If at first you don't succeed, call it version 1.0

ForeverZer0

I am curious why would you would need a common event to change the HP of the character, since this would be done automatically through the Scene_Item when the item is used. If you are trying to avoid the using menus at all when items are used, and using the boxes as you described above, it would make more sense. Other than that, if you don't want to make the little edit to the script, it's going to be tricky just using events.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

KK20

Quote from: ForeverZer0 on December 08, 2013, 12:34:37 pm
I am curious why would you would need a common event to change the HP of the character, since this would be done automatically through the Scene_Item when the item is used.

This.

Generally people make items call common events for the following:
- Open a new scene (e.g. Journal, Map)
- Effect is only visible on map (e.g. Escape Rope, Repel)
- Activate switches (e.g. "You used the Pokeflute. Snorlax woke up!")

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

G_G

He did say he was making his own abs. Maybe he has the characters health as a separate variable rather than using the built in functions to keep track of the actors actual health.

Seltzer Cole

Quote from: gameus on December 09, 2013, 12:31:03 am
He did say he was making his own abs. Maybe he has the characters health as a separate variable rather than using the built in functions to keep track of the actors actual health.


Yeah I am using a variable to keep track of it. It also displays your health on the screen by seeing what the variable is at so it knows how much to display. I would just use the regular commands like "Change HP" or "Change Parameters" to give you more HP or Heal you at save points but I realized that there is nothing relating towards your HP in Conditional Branches... Which means when it calls the common event to check how much HP you have to display it on screen, it couldn't. Also since I am using the equipment screen, I like how it displays your level. So I kept that feature and I don't want the game levels messing with your HP or me having to add in a hp curve to your level. It is just easier for me to use a variable.

But hey, thanks everyone for giving me some insight and explaining how the script of the inventory screen works when calling a common event. I will just end up adding two small boxes on your screen keyed to two keys so you can add whatever 2 items you want to those 2 boxes. Would be better that way so you wouldn't have to open your inventory screen constantly to heal...just to have it close on you.  :O.o:
You know you play video games to much when you put sunglasses on and whisper "Plus 10 Appearance"

If at first you don't succeed, call it version 1.0

Seltzer Cole

So I made a common events that can be called upon for your 2 hotkeys. The problem is setting the hotkeys. When I open my inventory and use an item, it of course closes and then calls the common event, works for me. The issue is letting the game know which item you just clicked so that the common event can set its variable to a specific digit which would indicate the item. I don't want to have 30 different common events for each and every item. Just use 1.

I tried giving the items different "states" so when you use the item it inflicts you, and then I can just check which infliction you have and that would tell me the item you selected...then it could assign you the hotkey of your preference.

The problem is that the only way to inflict someone is to use the item and then select your character. Is there a way to bypass selecting yourself? Like when you use an item for healing lets say, it makes you choose a "Scope" and I tried making BS State Changes so that I could check that to see the item you used. I want for when you use an item it auto state changes you to whatever I have it set to without even giving you the option of choosing a character to use the item on. Sounds like a simple fix but I have no scripting knowledge =\
You know you play video games to much when you put sunglasses on and whisper "Plus 10 Appearance"

If at first you don't succeed, call it version 1.0

KK20

Honestly, at this point, you really are better off just requesting a custom item scene. This is getting obscenely messy and confusing. I had to read your last post more than twice to understand it.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Seltzer Cole

December 09, 2013, 07:32:49 pm #22 Last Edit: December 09, 2013, 07:46:18 pm by Seltzer Cole
Quote from: KK20 on December 09, 2013, 04:36:18 pm
Honestly, at this point, you really are better off just requesting a custom item scene. This is getting obscenely messy and confusing. I had to read your last post more than twice to understand it.


I'm sorry. Sometimes I ramble a bit.   :^_^':

Put simply, when you use an item from the inventory (The one the game comes with) and it displays which character you wish to use the item on (Depending on the Scope you chose), is there a way to bypass this and have it automatically use the item on the main character instead of asking you who to use the item on (I have tried every scope and none of them automatically use the item). Doesn't matter what the item is or does (Could be a healing item for all I care).

With leaving Scope blank, I will not be able to assign it a "State Change" therefore not allowing my variable within my common event to know which item I am trying to use since the inventory menu has closed (Unless of course I make a common event for every item in the game).

If a custom item scene is what I need to request, I may just do that. But thank you for all your help!

Looks like the issue may be fixed in here,
Spoiler: ShowHide
# If effect scope is an ally
     if @item.scope >= 3
       # Activate target window
       @item_window.active = false
       @target_window.x = (@item_window.index + 1) % 2 * 304
       @target_window.visible = true
       @target_window.active = true
       # Set cursor position to effect scope (single / all)
       if @item.scope == 4 || @item.scope == 6
         @target_window.index = -1
       else
         @target_window.index = 0
       end
     # If effect scope is other than an ally
     else
       # If command event ID is valid
       if @item.common_event_id > 0
         # Command event call reservation
         $game_temp.common_event_id = @item.common_event_id
         # Play item use SE
         $game_system.se_play(@item.menu_se)
         # If consumable
         if @item.consumable
           # Decrease used items by 1
           $game_party.lose_item(@item.id, 1)
           # Draw item window item
           @item_window.draw_item(@item_window.index)
         end

But I don't know if it would be wise for me to go editing this without someones help...lol. I did set @target_window.visible = true to false so the window will not pop up but I still have to hit enter again to use the item.
You know you play video games to much when you put sunglasses on and whisper "Plus 10 Appearance"

If at first you don't succeed, call it version 1.0

G_G

You do know you can store an Actor's HP in a variable right?

Spoiler: ShowHide

KK20

Replace the section with this
Spoiler: ShowHide

      # If effect scope is an ally
      if @item.scope >= 3
        # Activate target window
        @item_window.active = true
        @target_window.x = (@item_window.index + 1) % 2 * 304
     #   @target_window.visible = true
     #   @target_window.active = true
        # Set cursor position to effect scope (single / all)
        if @item.scope == 4 || @item.scope == 6
          @target_window.index = -1
        else
          @target_window.index = 0
        end
       
       
      # If items are used up
      if $game_party.item_number(@item.id) == 0
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # If target is all
      if @target_window.index == -1
        # Apply item effects to entire party
        used = false
        for i in $game_party.actors
          used |= i.item_effect(@item)
        end
      end
      # If single target
      if @target_window.index >= 0
        # Apply item use effects to target actor
        target = $game_party.actors[@target_window.index]
        used = target.item_effect(@item)
      end
      # If an item was used
      if used
        # Play item use SE
        $game_system.se_play(@item.menu_se)
        # If consumable
        if @item.consumable
          # Decrease used items by 1
          $game_party.lose_item(@item.id, 1)
          # Redraw item window item
          @item_window.draw_item(@item_window.index)
        end
        # Remake target window contents
        @target_window.refresh
        # If all party members are dead
        if $game_party.all_dead?
          # Switch to game over screen
          $scene = Scene_Gameover.new
          return
        end
        # If common event ID is valid
        if @item.common_event_id > 0
          # Common event call reservation
          $game_temp.common_event_id = @item.common_event_id
          # Switch to map screen
          $scene = Scene_Map.new
          return
        end
      end
      # If item wasn't used
      unless used
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
      end
      return
     
     
     
      # If effect scope is other than an ally
      else

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Seltzer Cole

December 10, 2013, 06:48:58 pm #25 Last Edit: December 10, 2013, 06:53:25 pm by Seltzer Cole
Quote from: KK20 on December 10, 2013, 01:02:10 pm
Replace the section with this
Spoiler: ShowHide

     # If effect scope is an ally
     if @item.scope >= 3
       # Activate target window
       @item_window.active = true
       @target_window.x = (@item_window.index + 1) % 2 * 304
    #   @target_window.visible = true
    #   @target_window.active = true
       # Set cursor position to effect scope (single / all)
       if @item.scope == 4 || @item.scope == 6
         @target_window.index = -1
       else
         @target_window.index = 0
       end
       
       
     # If items are used up
     if $game_party.item_number(@item.id) == 0
       # Play buzzer SE
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     # If target is all
     if @target_window.index == -1
       # Apply item effects to entire party
       used = false
       for i in $game_party.actors
         used |= i.item_effect(@item)
       end
     end
     # If single target
     if @target_window.index >= 0
       # Apply item use effects to target actor
       target = $game_party.actors[@target_window.index]
       used = target.item_effect(@item)
     end
     # If an item was used
     if used
       # Play item use SE
       $game_system.se_play(@item.menu_se)
       # If consumable
       if @item.consumable
         # Decrease used items by 1
         $game_party.lose_item(@item.id, 1)
         # Redraw item window item
         @item_window.draw_item(@item_window.index)
       end
       # Remake target window contents
       @target_window.refresh
       # If all party members are dead
       if $game_party.all_dead?
         # Switch to game over screen
         $scene = Scene_Gameover.new
         return
       end
       # If common event ID is valid
       if @item.common_event_id > 0
         # Common event call reservation
         $game_temp.common_event_id = @item.common_event_id
         # Switch to map screen
         $scene = Scene_Map.new
         return
       end
     end
     # If item wasn't used
     unless used
       # Play buzzer SE
       $game_system.se_play($data_system.buzzer_se)
     end
     return
     
     
     
     # If effect scope is other than an ally
     else



Works flawlessly! I was all  :wacko: but now I am  :-*

;) lmao THANK YOU!

Quote from: gameus on December 09, 2013, 07:55:11 pm
You do know you can store an Actor's HP in a variable right?

Spoiler: ShowHide



Yeah I know that, but the issue was when you used an item it always wanted a "Scope" which would pop a window up in game, asking who to use the item on. I just wanted it to automatically use any selected item on you instead of asking who to use it on (You have no teammates in my game). But KK20 fixed the issue for me.
You know you play video games to much when you put sunglasses on and whisper "Plus 10 Appearance"

If at first you don't succeed, call it version 1.0

KK20

Funny thing too is that the fix was just copy-pasting the right stuff from update_target. Could be cleaner, but, you know, inherent laziness.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!