I'm hoping someone can help me with writing a script. I'm not really looking for free code as much as I'm looking for assistance figuring out how to implement something, so I can learn how to code better.
Right now I have a custom status menu with a standard help window. The user can select and scroll through the list of stats to see a description of what each one does (Though it's kind of broken, see below).
I now want to create a window that displays the actors current status effects (states) and populates information to the help window about each state. I understand I'll need a custom array that associates each state with a description, as RPG Maker XP does not provide state descriptions by default. I am using Blizz's states as icons scripts, if that helps.
I actually already have the framework for the window (I know how to create the window, make it active/inactive, set the index, the screenshot below is all in-game with the exception of the white text/icons), but I'm not entirely sure what the best way to draw each state and its associated icon on the list and assure it is properly selected and populated into the help window.
Here is a screenshot example:
Bonus question:
For some reason, my stats window isn't working properly. The first item on the list is selected properly, but nothing happens when I scroll (the index doesn't change?). Is it because I need to explicitly set the "commands"? In this case, I would happy to accept help, but I feel like I really need to figure it out on my own.
Here is the code:
class Window_Stats < Window_Selectable
include CMS_Config
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 152, 246)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = 8
@column_max = 1
@actor = actor
self.z += 10
self.active = false
self.index = -1
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...7
draw_actor_parameter(@actor, 0, i*32, i)
end
update_cursor_rect
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
#update cursor rectangle
update_cursor_rect
end
# Update cursor rectangle
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
# Get current row
row = @index / @column_max
# If current row is before top row
if row < self.top_row
# Scroll so that current row becomes top row
self.top_row = row
end
# If current row is more to back than back row
if row > self.top_row + (self.page_row_max - 1)
# Scroll so that current row becomes back row
self.top_row = row - (self.page_row_max - 1)
end
# Calculate cursor width
cursor_width = self.width / @column_max - 16
# Calculate cursor coordinates
x = 4
y = @index * 32
# Update cursor rectangle
self.cursor_rect.set(x, y, cursor_width, 32)
end
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.index < 0 ? "" : STAT_DESCRIPTIONS[@index], 0)
end
#--------------------------------------------------------------------------
# * Draw Parameters
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# type : parameter type (0-6)
#--------------------------------------------------------------------------
def draw_actor_parameter(actor, x, y, type)
case type
when 0
parameter_name = $data_system.words.atk
parameter_value = actor.atk
when 1
parameter_name = $data_system.words.pdef
parameter_value = actor.pdef
when 2
parameter_name = $data_system.words.mdef
parameter_value = actor.mdef
when 3
parameter_name = $data_system.words.str
parameter_value = actor.str
when 4
parameter_name = $data_system.words.dex
parameter_value = actor.dex
when 5
parameter_name = $data_system.words.agi
parameter_value = actor.agi
when 6
parameter_name = $data_system.words.int
parameter_value = actor.int
end
self.contents.font.color = system_color
self.contents.draw_text(x, y, 80, 32, parameter_name)
self.contents.font.color = normal_color
self.contents.draw_text(x + 80, y, 36, 32, parameter_value.to_s, 2)
end
end
Thanks everyone!