=begin
#==============================================================================#
# AMN YEA Status Addon - Actor Variables
# Version 1.01
# Author: AMoonlessNight
# Date: 01 Jun 2020
# Latest: 01 Jun 2020
#==============================================================================#
# UPDATE LOG
#------------------------------------------------------------------------------#
# 01 Jun 2020 - created the script
#==============================================================================#
# TERMS OF USE
#------------------------------------------------------------------------------#
# - Please credit AMoonlessNight or A-Moonless-Night
# - Please credit Yanfly and follow their terms of use
# - Free for non-commercial use; contact for commercial use
# - If you would like to edit/adjust this script, please make edits as a new
# script (do not edit this script directly) and provide proper credit
# - I'd love to see your game if you end up using one of my scripts
#==============================================================================#
This script is an addon for the YEA Ace Status Menu script, based off the
Actor Variables plugin for RPG Maker MV by Yanfly.
Description based off the YEP Actor Variable plugin:
This script lets you place variables into the Status Menu in a unique page
for display as actor data. These variables can come from a global or individual
source per actor. Variables listed in the GLOBAL_VARIABLES array in the editable
region below will be listed for all actors. Variables defined in the actor
noteboxes will be listed for that actor when displayed.
#==============================================================================#
You will need to set up the command in the original Yanfly script under COMMANDS
like so:
COMMANDS =[ # The order at which the menu items are shown.
[ :variables, "Variables"],
Use the following notetags to display variables in your Status Menu:
Actor Notetags:
<column X variables: Y>
<column X variables: Y, Y, Y>
<column X variables: Y to Z>
<column X variables: Y..Z>
This will display in column X the variable(s) Y. If using the 'Y to Z' or
'Y..Z' notetag, this will display all the variables from Y to Z (e.g. '1..5'
or '1 to 5' will show 1, 2, 3, 4, 5).
To display icons and change the display of your variables, write the name
of your variables like text codes in the Control Variables menu.
A variable name like this \i[42]Variable Name will show up with an icon.
However, if you wish to make notes that do not appear, you can place the
notes between << and >>. For example:
Hello <<You can't see me>>World!
will show up as 'Hello World!' because of the << and >> markers.
You can also set names in the NEW_NAMES editable region below.
=end
($imported ||= {})[:AMN_YEA_Status_Variables] = true
unless $imported["YEA-StatusMenu"]
url = "https://yanflychannel.wordpress.com/rmvxa/menu-scripts/ace-status-menu/"
message = "ERROR: \nDid not detect Yanfly Engine Ace - Ace Status Menu v1.02 \n" +
"\nPlease retrieve it from here: \n" + url
msgbox(message)
exit
end
module YEA::STATUS
#==============================================================================
# ** EDITABLE REGION BELOW
#------------------------------------------------------------------------------
# Change the values in the area below to suit your needs.
#==============================================================================
# Switch ID to show variables in the status menu. Set to 0 to have it always
# show in the status menu.
VAR_SWITCH = 0
# The font size for the variables; it can be a number, or you can set it to
# be the same as the Properties font size by using PROPERTIES_FONT_SIZE
VARIABLES_FONT_SIZE = PROPERTIES_FONT_SIZE
# These variables appear for every actor
GLOBAL_VARIABLES = [[],
[1,2,3], # column 1
[4], # column 2
[6], # column 3
]
# You can have as many columns as you like, but they may not display correctly.
# It is recommend that you stick with 2 or 3 columns
# The text displayed for each variable will be the name of the variable. To
# hide part of the text, put it inside double << >> brackets, e.g. <<hide>>
# You can use text codes in the names like you would regular messages, e.g.
# \c[3]Health\c[0]
# Alternatively, you can set new names below:
NEW_NAMES = {
# ID => "Name",
1 => "Health",
2 => "\\i[127]\\c[7]Stamina",
}
# These also accept text codes. Don't forget to double escape them:
# use \\ instead of \ , e.g. \\c[4] to change colour instead of \c[4]
#==============================================================================
# ** END OF EDITABLE REGION
#------------------------------------------------------------------------------
# Please do not edit below this point unless you know what you are doing.
#==============================================================================
end
class Game_Actor < Game_Battler
attr_reader :actor_variables
alias amn_yeasm_gameactor_setup setup
def setup(actor_id)
amn_yeasm_gameactor_setup(actor_id)
setup_actor_variables
end
def setup_actor_variables
@actor_variables = {}
YEA::STATUS::GLOBAL_VARIABLES.each_with_index do |vars, column|
vars.each { |v| @actor_variables[v] = column }
end
actor.note.split(/[\r\n]+/).each do |line|
case line
when /<column\s+(\d)\s+variables:\s+(.+)>/i
column = $1.to_i; var = $2
case var
when /\d+,/i
var.split(",").each { |v| @actor_variables[v.to_i] = column }
when /(\d+)\.{2}(\d+)/i, /(\d+)\s+to\s+(\d+)/i
($1.to_i..$2.to_i).to_a.each { |v| @actor_variables[v] = column }
when /\d+/i
@actor_variables[var.to_i] = column
end
end
end
end
end
class Window_StatusCommand < Window_Command
alias amn_yeasm_windstatuscmd_processcustomcmd process_custom_command
def process_custom_command(command)
if command[0] == :variables
return if YEA::STATUS::VAR_SWITCH > 0 && !$game_switches[YEA::STATUS::VAR_SWITCH]
add_command(command[1], command[0])
else
amn_yeasm_windstatuscmd_processcustomcmd(command)
end
end
end
class Window_StatusItem < Window_Base
def bg_colour; Color.new(0, 0, 0, translucent_alpha/2); end
alias amn_yeasm_windstatusitem_drawwindcontents draw_window_contents
def draw_window_contents
return draw_actor_variables if @command_window.current_symbol == :variables
amn_yeasm_windstatusitem_drawwindcontents
end
def draw_actor_variables
list = @actor.actor_variables.values.uniq
list.sort.each do |col|
columns = @actor.actor_variables.select { |k, v| v == col }.keys
draw_variables_list(columns, [col - 1, list.size - 1].min, list.size)
end
reset_font_settings
end
def item_rect_yea_column(index, size)
spacing = 12
rect = Rect.new
rect.width = (contents_width + spacing) / size - spacing
rect.height = contents_height
rect.x = index % size * (rect.width + spacing)
rect.y = 0
rect
end
def item_rect_yea(rect, index)
nrect = rect
rect.y = line_height * index
rect.height = line_height
nrect
end
def draw_text_ex_yea(x, y, text)
reset_font_settings
change_color(system_color)
contents.font.size = YEA::STATUS::VARIABLES_FONT_SIZE
text = convert_escape_characters(text)
pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
process_character(text.slice!(0, 1), text, pos) until text.empty?
reset_font_settings
end
def draw_variables_list(column, index, size)
rect = item_rect_yea_column(index, size)
column.each_with_index do |var, i|
nrect = item_rect_yea(rect, i)
contents.fill_rect(nrect.x+1, nrect.y+1, nrect.width-2, nrect.height-2, bg_colour)
name = YEA::STATUS::NEW_NAMES.key?(var) ? YEA::STATUS::NEW_NAMES[var] : $data_system.variables[var]
name = name.gsub(/<<(.*?)>>/i) {""}
draw_text_ex_yea(nrect.x + 4, nrect.y, name)
contents.font.size = YEA::STATUS::VARIABLES_FONT_SIZE
draw_text(nrect, $game_variables[var], 2)
end
end
end