#==============================================================================
# ** KIRA Talk Menu (List Version)
# Ver: 1.0
#------------------------------------------------------------------------------
# * Description:
# This script adds a "Talk" command to the main menu that displays a window
# with a list of current party members. When a character is selected, it
# updates a variable and calls a common event.
#------------------------------------------------------------------------------
# * Features:
# - Adds "Talk" command to the main menu
# - Displays a simple list of party members
# - Updates a variable with the selected character's ID
# - Calls a common event after selection
#------------------------------------------------------------------------------
# * Instructions:
# 1. Place this script in the Materials section of the Script Editor
# 2. Configure the settings below to set your preferences
# 3. Set up the common event that will be called when a character is selected
#==============================================================================
module KIRA
module TalkMenu
# Basic Settings
MENU_NAME = "Talk" # Name shown in the menu
VARIABLE_ID = 10 # Variable to store selected actor ID
COMMON_EVENT_ID = 2 # Common event to call after selection
# Window Settings
WINDOW_WIDTH = 400 # Width of the talk window
HELP_HEIGHT = 64 # Height of the help window
LIST_VISIBLE_ROWS = 8 # Number of visible rows in the list
# Excluded Actor IDs
EXCLUDED_ACTOR_IDS = [1, 7]
end
end
#==============================================================================
# ** Window_MenuCommand
#==============================================================================
class Window_MenuCommand < Window_Command
alias kira_talk_list_add_commands add_original_commands
def add_original_commands
kira_talk_list_add_commands
enabled = $game_party.members.any? { |actor| !KIRA::TalkMenu::EXCLUDED_ACTOR_IDS.include?(actor.id) }
add_command(KIRA::TalkMenu::MENU_NAME, :kira_talk, enabled)
end
end
#==============================================================================
# ** Scene_Menu
#==============================================================================
class Scene_Menu < Scene_MenuBase
alias kira_talk_list_create_command create_command_window
def create_command_window
kira_talk_list_create_command
@command_window.set_handler(:kira_talk, method(:command_kira_talk))
end
def command_kira_talk
SceneManager.call(Scene_KiraTalk)
end
end
#==============================================================================
# ** Scene_KiraTalk
#==============================================================================
class Scene_KiraTalk < Scene_MenuBase
def start
super
create_help_window
create_list_window
end
def create_help_window
x = (Graphics.width - KIRA::TalkMenu::WINDOW_WIDTH) / 2
y = (Graphics.height - total_window_height) / 2
@help_window = Window_KiraTalkHelp.new(x, y)
end
def create_list_window
x = (Graphics.width - KIRA::TalkMenu::WINDOW_WIDTH) / 2
y = @help_window.y + @help_window.height
@list_window = Window_KiraTalkList.new(x, y)
@list_window.set_handler(:ok, method(:on_select_ok))
@list_window.set_handler(:cancel, method(:return_scene))
@list_window.help_window = @help_window
end
def total_window_height
valid_members = $game_party.members.reject { |actor| KIRA::TalkMenu::EXCLUDED_ACTOR_IDS.include?(actor.id) }
list_rows = [valid_members.size, KIRA::TalkMenu::LIST_VISIBLE_ROWS].min
line_height = 24
list_height = list_rows * line_height + 32
return KIRA::TalkMenu::HELP_HEIGHT + list_height
end
def on_select_ok
actor = @list_window.selected_actor
if actor
$game_variables[KIRA::TalkMenu::VARIABLE_ID] = actor.id
$game_temp.reserve_common_event(KIRA::TalkMenu::COMMON_EVENT_ID)
SceneManager.goto(Scene_Map)
else
@list_window.activate
end
end
end
#==============================================================================
# ** Window_KiraTalkHelp
#==============================================================================
class Window_KiraTalkHelp < Window_Base
def initialize(x, y)
super(x, y, KIRA::TalkMenu::WINDOW_WIDTH, KIRA::TalkMenu::HELP_HEIGHT)
refresh
end
def refresh
contents.clear
text = "Who would you like to talk to?"
# Draw text with smaller vertical offset (6px from top)
draw_text(0, 6, contents_width, line_height, text, 1)
end
# Keep this method to maintain compatibility with the update_help calls
def update_text(actor)
end
end
#==============================================================================
# ** Window_KiraTalkList
#==============================================================================
class Window_KiraTalkList < Window_Selectable
attr_reader :help_window
def initialize(x, y)
@data = $game_party.members.reject { |actor| KIRA::TalkMenu::EXCLUDED_ACTOR_IDS.include?(actor.id) }
window_height = [KIRA::TalkMenu::LIST_VISIBLE_ROWS, @data.size].min * item_height + standard_padding * 2
super(x, y, KIRA::TalkMenu::WINDOW_WIDTH, window_height)
self.select(0)
refresh
activate
update_help
end
def help_window=(help_window)
@help_window = help_window
update_help
end
def update_help
if @help_window && selected_actor
@help_window.update_text(selected_actor)
end
end
def refresh
create_contents
draw_all_items
end
def item_max
@data ? @data.size : 0
end
def item_height
line_height
end
def selected_actor
@data[index] if index && index >= 0
end
def draw_item(index)
return unless @data && index < @data.size
actor = @data[index]
return unless actor
rect = item_rect(index)
rect.width -= 16
draw_text(rect.x + 8, rect.y, rect.width, rect.height, actor.name)
end
def process_handling
super
end
def process_cursor_move
last_index = @index
super
end
end