[ACE]Use Item Directly from the main menu

Hi,

I'm wondering if I'm over complicating this, but I'm looking for a way to create a main menu command that will automatically use an item, instead of having to go into the item menu and scrolling through items.

Basically, the item toggles the target's state between two different states. If target has state A, it will remove it and add State B and vice versa.

So the user would click the command, and it would give the user an option to select which party member to use it on. Then, the above would occur.

I'm open to other ways to do this through the menu, but trying to have it directly through the main menu options, rather than slogging through tons of menus.
I'd say you'll need a script for this. Maybe this one could help? I haven't used it myself, but it looks like it might do the job.
I'm wondering if I'm over complicating this,
yes

I can think of several different alternatives, but they depend on what exactly you want the player to do and what effect the states are supposed to have.

But one way to go would be to have the two states react to a switch by a plugin for passive states.

But for more details you need to describe what this is about.
yes

I can think of several different alternatives, but they depend on what exactly you want the player to do and what effect the states are supposed to have.

But one way to go would be to have the two states react to a switch by a plugin for passive states.

But for more details you need to describe what this is about.
The two states are essentially stances I want each character to have, and the menu option would change what stance they had at the start of battle.

So through the menu option, I could change Ralph from “offensive stance” to “defensive stance”, each with its own features and benefits.

They could change in battle via a skill, but i want the player to have any easy way to change stances via the menu as well.
The two states are essentially stances I want each character to have, and the menu option would change what stance they had at the start of battle.

So through the menu option, I could change Ralph from “offensive stance” to “defensive stance”, each with its own features and benefits.

They could change in battle via a skill, but i want the player to have any easy way to change stances via the menu as well.
Where in the menu would you like the stance command to be?
Where in the menu would you like the stance command to be?
Preferably right under “formation”
Preferably right under “formation”
And does each character have a unique set of stance states or is it the same two for everyone?
And does each character have a unique set of stance states or is it the same two for everyone?
Same for each!
Same for each!
Is it always going to be the same so it can be hardcoded or would you prefer to have a little config bit where you can customise it in case it changes?
Is it always going to be the same so it can be hardcoded or would you prefer to have a little config bit where you can customise it in case it changes?
I think let’s have a config, you can never be too sure lol
Here you go!

Ruby:
=begin
#===============================================================================
 Title: Stances
 Author: Trihan
 Date: Jan 21, 2023
--------------------------------------------------------------------------------
 ** Change log
 Jan 21, 2023
   - Initial release
--------------------------------------------------------------------------------   
 ** Terms of Use
 * Free to use for any purpose
 * No real support. The script is provided as-is
 * Will do bug fixes, but no compatibility patches
 * Features may be requested but no guarantees, especially if it is non-trivial
 * Credits to Trihan in your project
 * Preserve this header
--------------------------------------------------------------------------------
 ** Description
 
 This script adds the ability to set stance states and gives the player a menu
 command that will switch stances without having to go into a submenu.
 
--------------------------------------------------------------------------------
 ** Installation
 
 Place this below Materials and above Main.

--------------------------------------------------------------------------------
 ** Usage 
 
 Plug and play.
 
#===============================================================================
=end
$imported = {} if $imported.nil?
$imported["TLB_Stances"] = true
#===============================================================================
# ** Configuration
#===============================================================================
module TLB
  module Stances
    
    # The ID of stance A state
    StanceA = 24
    
    # The ID of stance B state
    StanceB = 25

#===============================================================================
# ** Rest of Script
#===============================================================================    
  end
end

class Window_MenuCommand < Window_Command
  alias :tlb_add_orig_comm_8vh8 :add_original_commands
  def add_original_commands
    tlb_add_orig_comm_8vh8
    add_command("Stance switch", :stance, true)
  end
end

class Scene_Menu < Scene_MenuBase
  alias :tlb_create_comm_win_4ws5 :create_command_window
  def create_command_window
    tlb_create_comm_win_4ws5
    @command_window.set_handler(:stance,    method(:command_personal))
  end
  
  alias :tlb_on_pers_ok_3og9 :on_personal_ok
  def on_personal_ok
    case @command_window.current_symbol
    when :stance
      actor = $game_party.menu_actor
      stance_a = TLB::Stances::StanceA
      stance_b = TLB::Stances::StanceB
      if actor.state?(stance_a)
        actor.add_state(stance_b)
        actor.remove_state(stance_a)
      elsif actor.state?(stance_b)
        actor.add_state(stance_a)
        actor.remove_state(stance_b)
      else
        actor.add_state(stance_a)
      end
      actor.result.added_states = []
      actor.result.removed_states = []
      @status_window.refresh
      @status_window.unselect
      @command_window.activate
    else
      tlb_on_pers_ok_3og9
    end
  end
end
Here you go!

Ruby:
=begin
#===============================================================================
 Title: Stances
 Author: Trihan
 Date: Jan 21, 2023
--------------------------------------------------------------------------------
 ** Change log
 Jan 21, 2023
   - Initial release
--------------------------------------------------------------------------------  
 ** Terms of Use
 * Free to use for any purpose
 * No real support. The script is provided as-is
 * Will do bug fixes, but no compatibility patches
 * Features may be requested but no guarantees, especially if it is non-trivial
 * Credits to Trihan in your project
 * Preserve this header
--------------------------------------------------------------------------------
 ** Description
 
 This script adds the ability to set stance states and gives the player a menu
 command that will switch stances without having to go into a submenu.
 
--------------------------------------------------------------------------------
 ** Installation
 
 Place this below Materials and above Main.

--------------------------------------------------------------------------------
 ** Usage
 
 Plug and play.
 
#===============================================================================
=end
$imported = {} if $imported.nil?
$imported["TLB_Stances"] = true
#===============================================================================
# ** Configuration
#===============================================================================
module TLB
  module Stances
   
    # The ID of stance A state
    StanceA = 24
   
    # The ID of stance B state
    StanceB = 25

#===============================================================================
# ** Rest of Script
#===============================================================================   
  end
end

class Window_MenuCommand < Window_Command
  alias :tlb_add_orig_comm_8vh8 :add_original_commands
  def add_original_commands
    tlb_add_orig_comm_8vh8
    add_command("Stance switch", :stance, true)
  end
end

class Scene_Menu < Scene_MenuBase
  alias :tlb_create_comm_win_4ws5 :create_command_window
  def create_command_window
    tlb_create_comm_win_4ws5
    @command_window.set_handler(:stance,    method(:command_personal))
  end
 
  alias :tlb_on_pers_ok_3og9 :on_personal_ok
  def on_personal_ok
    case @command_window.current_symbol
    when :stance
      actor = $game_party.menu_actor
      stance_a = TLB::Stances::StanceA
      stance_b = TLB::Stances::StanceB
      if actor.state?(stance_a)
        actor.add_state(stance_b)
        actor.remove_state(stance_a)
      elsif actor.state?(stance_b)
        actor.add_state(stance_a)
        actor.remove_state(stance_b)
      else
        actor.add_state(stance_a)
      end
      actor.result.added_states = []
      actor.result.removed_states = []
      @status_window.refresh
      @status_window.unselect
      @command_window.activate
    else
      tlb_on_pers_ok_3og9
    end
  end
end
Thank you! I’ll test it out first chance I get!

Also how did you know that I had the stances at state 24/25; that’s crazy LOL.
Thank you! I’ll test it out first chance I get!

Also how did you know that I had the stances at state 24/25; that’s crazy LOL.
That's literally just divine providence; I was having an issue with the states not adding so I changed the IDs because I thought it might be because my test ones had movement restrictions on them, but it turned out the actual problem was that if @result has added_states or removed_states matching the ID you're trying to add/remove, it won't do it because it's already done it. But that only really works in battle which is why the menu command blanks them out again afterwards.
That's interesting.... I'll keep that in mind.

Well, it works perfectly, Thank you for the help!

I'll be sure to give you credits for this snippet!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/ace-use-item-directly-from-the-main-menu.154281/