Ruby/RGSSx questions that don't deserve their own thread

They are "hidden" in the dll file, I guess.

But since you can read all of the RPG::Stuffs classes from the help files, you don't really need to directly see it in the editor itself.

Just enter the class and modify it how you want.

In order to initialize a starting value for a new instance variable in those classes, you should use the DataManager module's 'load_database' method.

That is the safest way to add new instance variables there, in case you need those new instance variables in another class' initialize method too (for example, you might need a variable from RPG::Actor in the initialization of the Game_Actor class). Alias that method and call your new method (which you made in those RPG::Stuffs classes) on the selected classes after the alias.
Okay, so I have the Data_Manager script set to load my mystuff.rvdata2 file and it works. Is what you're saying that I should have code in mystuff.rvdata2 to alias a method from, for example, RPG::skills? I seem to be confusing myself the further I go with this, although part of that's with how I created my *.rvdata2 file to begin with...

Edit: I made a workaround by making a class then defining how to get the name, id, etc. from a nested array... Will I have to load this class into the actor script and any other scripts i plan on using it in, or will it be accessible to them without having to do Class.new in each? I noticed when I put "initialize" at the start of the class (defining it later), RPGMaker gave an error saying that the class was already initialized.
This really is not a "question that does not deserve its own thread"
If its shared and needs only one instance, just make it a module... And no, you dont need to load them in any class that will use it, if by load you mean making a variable or sorts in that class that will handle your new class/object.

I'd so something like

Code:
module MyData@mydata = load_data(path)def self.name  #get from array @mydataend
Then if youblike to call it from any other class just do
Code:
MyData.name
You could always alias the initialize method of that class to create an initial value for the instance variables.. And just make them as attr_accessor then you can access them from outside calls..
Sometimes that won't work, no idea why thou.For example:

Spoiler
class RPG::Skill < RPG::UsableItem attr_accessor 😛aram_reqs alias testing_init7765 initialize def initialize testing_init7765 init_param_reqs end def init_param_reqs @param_reqs = [] if @note =~ /p_reqs = <(\d+[ ].*(?:\s*,\s*\d+[ ].*)*)>/i $1.split(", ").each do |info| info =~ /(\d+) (.*)/i @param_reqs << [$1.to_i, $2] # [value, stat] end end end end
So, I got my new variable, right?

If I try to use it here:

Spoiler
class Game_Actor < Game_Battler def learn_skill(skill_id) if $data_skills[skill_id].param_reqs == [] || $data_skills[skill_id].param_reqs.all? { |req| Skill_PReq.req_grabber(self,req) == true } unless skill_learn?($data_skills[skill_id]) @skills.push(skill_id) @skills.sort! end end endend
(Ignore the 'req_grabber' module method, it's irrelevant now.)

I will get a nice error saying "undefined method 'all?' for nil class" right on hitting new game, which means that for some reason, my new variable for RPG::Skill is not initialized yet at all, when the initialization of the learned skills for actors is called.

Now, if I move my initialization method calling for my new variable right at the end of DataManager's 'load_database' method instead of directly aliasing the initialization method of RPG::Skill like this:

Spoiler
module DataManager class <<self; alias load_skill_preqs5814 load_database; end def self.load_database load_skill_preqs5814 load_skill_preqs_notetags end def self.load_skill_preqs_notetags $data_skills.each do |skill| next if skill.nil? skill.init_param_reqs end endend
It suddenly works like a charm.

I changed nothing in my initialization method made in RPG::Skill, just moved the method call to the 'load_database' method.

I don't know why one works and why the other doesn't, but ever since I encountered the first issue like this, I always just use the DataManager method to avoid those errors popping out of nowhere.
This really is not a "question that does not deserve its own thread"
It was meant to be when I started, then I found out I didn't understand half of the answers >_> I wound up over complicating and confusing myself, sorry.

If its shared and needs only one instance, just make it a module... And no, you dont need to load them in any class that will use it, if by load you mean making a variable or sorts in that class that will handle your new class/object.

I'd so something like

module MyData@mydata = load_data(path)def self.name #get from array @mydataendThen if youblike to call it from any other class just do
Code:
MyData.name
That did it, thanks. Anyone got a link for a tutorial on modules?
@Sixth - and that approach is quite the old, non already-saved file friendly. A new, more friendly approach is that you have a method which you use to get those values, if the variable is nil, you initialize it. That way it will work even with save files made before the script was added. That will also ensure that it will be initialized before usage. The point might be irrelevant for the RPG::X classes (or those accessed by $data_x) as they're not saved into the save file, but I do think it's still better to practice this method. As for your other init problem, I never experienced that so far...


@Shakura - the help file
hi, new question here...

is it possible to show images in a Window_Selectable window?

I try to build a new ... mini menu, with maximal 6 selectable items. and I want to add an image for the selections... I show you a picture..

[IMG]http://i.imgur.com/B2XiXC2.png[/IMG]

I managed that I have 3 items in each row and a total of 2 rows... and I want a image inside the selectables, is this possible?
Yes, you can do it, similiar with Window_ItemList that drawing item icons by using blt method on window's contents.
alright, I have this so far...

[IMG]https://dl.dropboxusercontent.com/u/30480034/screenshot_22-07-2015%2019.56.00.png[/IMG]

problem is, the image is above the selectable and not within it's rectangle... I tried to change the z value, but it doesn't work... hmm... 

ah btw: this is the code to display the image:

Code:
    scroll = Sprite.new()    scroll.bitmap = Cache.picture("paper_scroll")    scroll.z = 0    contents.blt(0, 0, scroll.bitmap, scroll.bitmap.rect)
Yeah, the cursor is below window contents, and I don't know how to change this since bitmap doesn't have Z coordinate.

But if you want to make a background for the window, you could just create a new sprite rather then using blt. Then set the sprite coordinate according to the window. Your window have to be transparent though.
nah, it shouldn't be a new background, I just want an image inside the cursor. hm... that must be possible... dang it.
You either draw it on the window's contents (with the blt method) OR use sprites to display them, not both.

The cursor's Z is always 1 less than the window itself, and it is treated as a separate sprite which follows the cursor.

In order to put your image below the cursor, you need to increase the window's Z value, let's set it to 50.

Than the Z value for the new sprites should be anything between 1 (or 0 if you create them after the map background picture) and 48. That way, they will be under the cursor and still visible.

If you will use the sprite method (the only way to put them under the cursor, as far as I know), you will need to create a separate sprite for each item in your selectable window, and position them using the item_rect method (so that you don't have to bother much with their placement). Make an array to store these sprites, and you can use the item_rect method easily that way.

Like:

Spoiler
def create_new_sprites @pics = [] item_max.times do |i| @pics = Sprite.new @pics.bitmap = Cache.picture("pic name") @pics.x = item_rect(i).x @pics.y = item_rect(i).y @pics.z = 5 endend
Just make sure that these sprites are correctly disposed before exiting the scene (or before they are recreated in case you need to refresh them for something).

But if your window will always show 6 items, you can simply use a background sprite placed on top of the map background, but still below the window. That would do the job too for that case.

You can also make these images a tad bit smaller than the cursor itself. That way it doesn't matter if they are placed above or under, they will be visible anyway. You can use the blt method too this way.
hi, thanks for your help!

I think I go with it that the images are below the whole window. the Z value is 99, if it is 100, then the images are above the window and the curser and the text of the curser is not readable anymore.

btw the text. as you can see in the previous pictures, the cursor is bigger than normal. but the text is only in the middle of the cursor and doesn't begin from the top. I use KilloZapits word wrapper, just in case...

how do I manage that the text start from the top of the cursor?
Stupid question:

How to get actor ID in scripts?

Not $game_actors[1] ~ I want something like this:

For example let's say I want to draw an actor's HP next to him.

So... actor 1 has written HP of actor 1

actor 2 - HP of actor 2 etc.

I know I can make:

case actor.id

when 1

blah

when 2

blah

...

But is there a quicker way to avoid making walls of when's?

something like $game_actors[1].hp ~ but make it to take the actor ID automatically?
hm.. you can write this I think...

Code:
$game_actors.each do |actor|  actor.hp # do something with actors hp...end
It depends where you want to show that.

If it is in a selectable window, you can use $game_party.members[index].hp in the 'draw_item' method of the window.

Or if you want to draw it elsewhere (but still party member related), you can use something like this:

$game_party.members.each_with_index do |member,i| draw_text(x,y,w,h,member.hp)endAdjust the position and size of the text as you see fit.You can use the 'i' variable to adjust the position dynamically for each drawn HP text. It starts from 0 and increases by 1 after each HP text drawn.

In short, you need to make a dynamic method which changes the ID automatically based on your own conditions.

If you use the $game_actors method instead of $game_party.members, make sure to put a nil check in your method (like: 'if !$game_actors.nil?' or 'if !actor.nil?'), or else you risk getting a NoMethod error.
I'm sorry ~it seems that even "case actor.id" doesn't work, so there is probably something with class etc.
Dammit my scripting skills...
I have something like this:

Spoiler
Hbvxlvh.png
The "case" above works - it draws different icons for each actor.
But the "case" below throws error at me.
 
@ FeaR616 I tried that:
3lwvEzf.png


Result:

38AzCYB.png


Basically I want to change gauge width based on actor's max HP.

I'll try Sixth's method now...

WtvmtpT.png


It seems it doesn't work ~ I doesn't crash, but the width isn't changed when increasing max HP and it takes only one width for every party member.

$game_party.members.each_with_index do |member,i| dw = member.mhp / 10 endI'm really sorry for my scripting skills ~ I'm new to it and I don't understand many things...
Nothing will change unless you refresh (clear and redraw) the window itself after each change.

You can do that by making a refresh method which is called each time the MHP is changed.

Also, any kind of drawing method needs to be put inside the iteration, or else you 'dw' variable will get the last party member's value only, and all your gauges will be the same width.

It would help if you would tell us where do you want to draw these things. If you do this in a 'draw_item' method of a selectable window, the only thing you need to is change the ID to 'index' in the drawing line.

dw = $game_party.members[index].mhp/10If you are doing it in a regular Window_Base class, you could do it like:
Code:
$game_party.members.each_with_index do |member,i|  dw = member.mhp/10  draw_gauge(x,y*i,dw,rate,col1,col2)end
The above code would draw a gauge for each party members, and the gauges would line up vertically.The width of the gauge will be the MHP/10 formula for each member.

The code on the screenshot is wrong, btw. You can't define a method inside a method, I think. And it seems that you did exactly that, because I can't see the 'end' line of the previous method definition on your screenshot.
oh my god, that was a pain in the ass!!

this is what I got so far...

[IMG]http://i.imgur.com/wfI8Qjj.png[/IMG]

not totally satisfied because the images are either under the windo or above everything, but I think this goes well. just the dots and commas are placed strangely. oO

I tried it with regular expressions... /\w+|[\\.|\\,]/  but it doesn't get the dots or commas... =/
Yeah, I kinda realized that there are problems with these methods etc.

This is the script (I hope I can paste that here, if not - sorry)

Line: 368

Spoiler
#==============================================================================# # ▼ Yanfly Engine Ace - Ace Menu Engine v1.08# -- Modified by: Doogy # -- Last Updated: 2012.01.03# -- Level: Normal, Hard# -- Requires: n/a# #==============================================================================$imported = {} if $imported.nil?$imported["YEA-AceMenuEngine"] = true#==============================================================================# ▼ Updates# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 2015.01.17 - Display update MP gauge behave the same way as TP gauge (hidden if no skill use it).# 2012.01.03 - Compatibility Update: Ace Item Menu# 2012.01.01 - Compatibility Update: Kread-EX's Synthesis# - Compatibility Update: Kread-EX's Grathnode Install# - Compatibility Update: Yami's Slot Battle# 2011.12.23 - Script efficiency optimized.# 2011.12.19 - Compatibility Update: Class System# 2011.12.15 - Updated for better menu MP/TP gauge management.# 2011.12.13 - Compatibility Update: Ace Equip Engine# 2011.12.07 - Update to allow for switches to also hide custom commands.# 2011.12.06 - Started Script and Finished.# #==============================================================================# ▼ Introduction# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# The menu system in RPG Maker VX Ace is great. However, it lacks the user# customization that RPG Maker 2003 allowed. With this script, you can add,# remove, and rearrange menu commands as you see fit. In addition to that, you# can add in menu commands that lead to common events or even custom commands# provided through other scripts.# # This script also provides window appearance management such as setting almost# all command windows to be center aligned or changing the position of the# help window. You can also opt to show the TP Gauge in the main menu as well# as in the skill menu.# #==============================================================================# ▼ Instructions# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# To install this script, open up your script editor and copy/paste this script# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.# # Edit the settings in the module below as you see fit.# #==============================================================================# ▼ Compatibility# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that# it will run with RPG Maker VX without adjusting.# #==============================================================================module YEA module MENU #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - General Menu Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # This changes the way menus appear in your game. You can change their # alignment, and the location of the help window, Note that any non-Yanfly # Engine Ace scripts may not conform to these menu styles. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- HELP_WINDOW_LOCATION = 0 # 0-Top, 1-Middle, 2-Bottom. COMMAND_WINDOW_ALIGN = 1 # 0-Left, 1-Middle, 2-Right. # These settings below adjust the visual appearance of the main menu. # Change the settings as you see fit. MAIN_MENU_ALIGN = 0 # 0-Left, 1-Middle, 2-Right. MAIN_MENU_RIGHT = false # false-Left, true-Right. MAIN_MENU_ROWS = 20 # Maximum number of rows for main menu. DRAW_TP_GAUGE = true # If true, draws TP in the main menu. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - Main Menu Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # These settings adjust the main menu, the order at which commands appear, # what text is displayed, and what the commands are linked to. Here's a # list of which commands do what: # # ------------------------------------------------------------------------- # :command Description # ------------------------------------------------------------------------- # :item Opens up the item menu. Default menu item. # :skill Opens up the skill menu. Default menu item. # :equip Opens up the equip menu. Default menu item. # :status Opens up the status menu. Default menu item. # :formation Lets player manage party. Default menu item. # :save Opens up the save menu. Default menu item. # :game_end Opens up the shutdown menu. Default menu item. # # :class Requires YEA - Class System # # :gogototori Requires Kread-EX's Go Go Totori! Synthesis # :grathnode Requires Kread-EX's Grathnote Install # :sslots Requires Yami's YSA - Slot Battle #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- COMMANDS =[ # currencies/gallery :item, # Opens up the item menu. Default menu item. :equip, # Opens up the equip menu. Default menu item. :skill, # Opens up the skill menu. Default menu item. :status, # Opens up the status menu. Default menu item. :learn, # Opens up the learn skill menu. :states, # Opens up the state viewer menu. :bestiary, # Opens up the bestiary menu. :music, # Opens up the music room menu. 😛ictures, # Opens up the picture gallery menu. :formation, # Lets player manage party. Default menu item. :save, # Opens up the save menu. Default menu item. :game_end, # Opens up the shutdown menu. Default menu item. # :class, # Requires YEA - Class System. # :event_1, # Launches Common Event 1. Common Event Command. # :event_2, # Launches Common Event 2. Common Event Command. # :debug, # Opens up debug menu. Custom Command. # :shop, # Opens up a shop to pawn items. Custom Command. ] # Do not remove this. #-------------------------------------------------------------------------- # - Common Event Commands - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # If you insert one of the following commands into the COMMANDS array, the # player can trigger a common event to launch. You can disable certain # commands in the menu by binding them to a switch. If you don't want to # disable them, set the switch to 0 and it will always be enabled. The # ShowSwitch will prevent a command from appear if that switch is false. # Set it to 0 for it to have no impact. #-------------------------------------------------------------------------- COMMON_EVENT_COMMANDS ={ # :command => ["Display Name", EnableSwitch, ShowSwitch, Event ID], :event_1 => [ "Camp", 11, 0, 1], :event_2 => [ "Synthesis", 0, 0, 2], } # Do not remove this. #-------------------------------------------------------------------------- # - Custom Commands - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # For those who use scripts that may lead to other menu scenes, use this # hash to manage custom commands that run specific script calls. You can # disable certain commands in the menu by binding them to a switch. If you # don't want to disable them, set the switch to 0. The ShowSwitch will # prevent a command from appear if that switch is false. Set it to 0 for # it to have no impact. #-------------------------------------------------------------------------- CUSTOM_COMMANDS ={ # :command => ["Display Name", EnableSwitch, ShowSwitch, Handler Method], :debug => [ "Debug", 0, 0, :command_debug], :shop => [ "Shop", 12, 0, :command_shop], :gogototori => ["Synthesis", 0, 0, :command_totori], :grathnode => [ "Grathnode", 0, 0, :command_install], :states => ["Lista statusów", 0, 0, :state_list], :bestiary => [ "Bestiariusz", 0, 0, :monster_book], :music => ["Kącik muzyczny", 0, 0, :music_room], 😛ictures => ["Galeria obrazów", 0, 0, 😛ic_gallery], :learn => ["Szkolenie", 0, 0, :learn_skills], } # Do not remove this. end # MENUend # YEA#==============================================================================# ▼ Editting anything past this point may potentially result in causing# computer damage, incontinence, explosion of user's head, coma, death, and/or# halitosis so edit at your own risk.#==============================================================================#==============================================================================# ■ Window_MenuCommand#------------------------------------------------------------------------------# This class is kept towards the top of the script to provide easier access.#==============================================================================class Window_MenuCommand < Window_Command #-------------------------------------------------------------------------- # overwrite method: make_command_list #-------------------------------------------------------------------------- def make_command_list for command in YEA::MENU::COMMANDS case command #--- Default Commands --- when :item add_command(Vocab::item, :item, main_commands_enabled) when :skill add_command(Vocab::skill, :skill, main_commands_enabled) when :equip add_command(Vocab::equip, :equip, main_commands_enabled) when :status add_command(Vocab::status, :status, main_commands_enabled) when :formation add_formation_command when :save add_original_commands add_save_command when :game_end add_game_end_command #--- Yanfly Engine Ace Commands --- when :class next unless $imported["YEA-ClassSystem"] add_class_command #--- Imported Commands --- when :sslots next unless $imported["YSA-SlotBattle"] add_sslots_command when :grathnode next unless $imported["KRX-GrathnodeInstall"] process_custom_command(command) when :gogototori next unless $imported["KRX-AlchemicSynthesis"] process_custom_command(command) #--- Imported Commands --- else process_common_event_command(command) process_custom_command(command) end end end #-------------------------------------------------------------------------- # new method: process_common_event_command #-------------------------------------------------------------------------- def process_common_event_command(command) return unless YEA::MENU::COMMON_EVENT_COMMANDS.include?(command) show = YEA::MENU::COMMON_EVENT_COMMANDS[command][2] continue = show <= 0 ? true : $game_switches[show] return unless continue text = YEA::MENU::COMMON_EVENT_COMMANDS[command][0] switch = YEA::MENU::COMMON_EVENT_COMMANDS[command][1] ext = YEA::MENU::COMMON_EVENT_COMMANDS[command][3] enabled = switch <= 0 ? true : $game_switches[switch] add_command(text, command, enabled, ext) end #-------------------------------------------------------------------------- # new method: process_custom_command #-------------------------------------------------------------------------- def process_custom_command(command) return unless YEA::MENU::CUSTOM_COMMANDS.include?(command) show = YEA::MENU::CUSTOM_COMMANDS[command][2] continue = show <= 0 ? true : $game_switches[show] return unless continue text = YEA::MENU::CUSTOM_COMMANDS[command][0] switch = YEA::MENU::CUSTOM_COMMANDS[command][1] enabled = switch <= 0 ? true : $game_switches[switch] add_command(text, command, enabled) end end # Window_MenuCommand#==============================================================================# ■ Menu#==============================================================================module Menu #-------------------------------------------------------------------------- # self.help_window_location #-------------------------------------------------------------------------- def self.help_window_location return YEA::MENU::HELP_WINDOW_LOCATION end #-------------------------------------------------------------------------- # self.command_window_align #-------------------------------------------------------------------------- def self.command_window_align return YEA::MENU::COMMAND_WINDOW_ALIGN end #-------------------------------------------------------------------------- # self.main_menu_align #-------------------------------------------------------------------------- def self.main_menu_align return YEA::MENU::MAIN_MENU_ALIGN end #-------------------------------------------------------------------------- # self.main_menu_right #-------------------------------------------------------------------------- def self.main_menu_right return YEA::MENU::MAIN_MENU_RIGHT end end # Menu#==============================================================================# ■ Game_Actor#==============================================================================class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # new method: draw_mp? #-------------------------------------------------------------------------- def draw_mp? for skill in skills next unless added_skill_types.include?(skill.stype_id) return true if skill.mp_cost > 0 end return false end #-------------------------------------------------------------------------- # new method: draw_tp? #-------------------------------------------------------------------------- def draw_tp? return false unless $data_system.opt_display_tp for skill in skills next unless added_skill_types.include?(skill.stype_id) return true if skill.tp_cost > 0 end return false end end # Game_Actor#==============================================================================# ■ Window_Base#==============================================================================class Window_Base < Window #-------------------------------------------------------------------------- # overwrite method: draw_actor_simple_status #-------------------------------------------------------------------------- def draw_actor_simple_status(actor, dx, dy) dy -= line_height / 2 draw_actor_name(actor, dx, dy) draw_actor_level(actor, dx, dy + line_height * 1) #draw_actor_icons(actor, dx, dy + line_height * 2) dw = contents.width - dx - 124 draw_actor_icons(actor, dx, dy + line_height * 2, 200) if $game_switches[3] == true draw_icon(109, dx + 100, dy) else end case actor.id when 1 draw_icon(106, dx + 120, dy) draw_image(dx + 180, dy, "Graphics/Pictures/Stamina_Back.png") when 2 draw_icon(107, dx + 120, dy) when 3 draw_icon(108, dx + 120, dy) when 4 draw_icon(108, dx + 120, dy) when 5 draw_icon(106, dx + 120, dy) when 6 draw_icon(107, dx + 120, dy) end self.contents.font.color = Color.new(125,200,200) draw_text(dx, dy, dw, line_height * 7, " " + actor.jp.group + " LP") self.contents.font.color = normal_color draw_actor_class(actor, dx + 150, dy, dw) ############################ def draw_gauge(dx, dy, dw, rate, color1, color2) #dw = $game_actors[actor.id].mhp / 10 #nope didn't work dw = $game_actors[1].mhp / 10 # works and refreshes automatically fill_w = [(dw * rate).to_i, dw].min gauge_h = 5 gauge_y = dy + line_height - 2 - gauge_h outline_colour = gauge_back_color outline_colour.alpha = translucent_alpha contents.fill_rect(dx, gauge_y-1, dw+2, gauge_h+2, outline_colour) dx += 1 contents.fill_rect(dx, gauge_y, dw, gauge_h, gauge_back_color) contents.gradient_fill_rect(dx, gauge_y, fill_w, gauge_h, color1, color2) end ################################# draw_actor_hp(actor, dx + 120, dy + line_height * 1, dw) ###################################### def draw_gauge(dx, dy, dw, rate, color1, color2) dw -= 2 fill_w = [(dw * rate).to_i, dw].min gauge_h = 10 gauge_y = dy + line_height - 2 - gauge_h outline_colour = gauge_back_color outline_colour.alpha = translucent_alpha contents.fill_rect(dx, gauge_y-1, dw+2, gauge_h+2, outline_colour) dx += 1 contents.fill_rect(dx, gauge_y, dw, gauge_h, gauge_back_color) contents.gradient_fill_rect(dx, gauge_y, fill_w, gauge_h, color1, color2) end ################################################### draw_exp(actor, dx + 120, dy + line_height + 48, dw) if YEA::MENU:😀RAW_TP_GAUGE && actor.draw_tp? && !actor.draw_mp? draw_actor_tp(actor, dx + 120, dy + line_height + 32, dw) elsif YEA::MENU:😀RAW_TP_GAUGE && actor.draw_tp? && actor.draw_mp? if $imported["YEA-BattleEngine"] draw_actor_tp(actor, dx + 120, dy + line_height + 32, dw) draw_actor_mp(actor, dx + 120, dy + line_height + 16, dw) else draw_actor_mp(actor, dx + 120, dy + line_height + 16, dw) draw_actor_tp(actor, dx + 120, dy + line_height + 32, dw) end elsif YEA::MENU:😀RAW_TP_GAUGE && actor.draw_mp? draw_actor_mp(actor, dx + 120, dy + line_height + 16, dw) end end end # Window_Base#==============================================================================# ■ Window_Command#==============================================================================class Window_Command < Window_Selectable #-------------------------------------------------------------------------- # overwrite method: alignment #-------------------------------------------------------------------------- def alignment return Menu.command_window_align end end # Window_Command#==============================================================================# ■ Window_MenuCommand#==============================================================================class Window_MenuCommand < Window_Command #-------------------------------------------------------------------------- # alias method: init_command_position #-------------------------------------------------------------------------- class <<self; alias init_command_position_ame init_command_position; end def self.init_command_position init_command_position_ame @@last_command_oy = nil end #-------------------------------------------------------------------------- # overwrite method: visible_line_number #-------------------------------------------------------------------------- def visible_line_number return [[item_max, YEA::MENU::MAIN_MENU_ROWS].min, 1].max end #-------------------------------------------------------------------------- # overwrite method: alignment #-------------------------------------------------------------------------- def alignment return Menu.main_menu_align end #-------------------------------------------------------------------------- # alias method: process_ok #-------------------------------------------------------------------------- alias window_menucommand_process_ok_ame process_ok def process_ok @@last_command_oy = self.oy window_menucommand_process_ok_ame end #-------------------------------------------------------------------------- # alias method: select_last #-------------------------------------------------------------------------- alias window_menucommand_select_last_ame select_last def select_last window_menucommand_select_last_ame self.oy = @@last_command_oy unless @@last_command_oy.nil? @@last_command_oy = nil end end # Window_MenuCommand#==============================================================================# ■ Scene_Menu#==============================================================================class Scene_Menu < Scene_MenuBase #-------------------------------------------------------------------------- # alias method: start #-------------------------------------------------------------------------- alias scene_menu_start_ame start def start scene_menu_start_ame relocate_windows end #-------------------------------------------------------------------------- # new method: relocate_windows #-------------------------------------------------------------------------- def relocate_windows return unless Menu.main_menu_right @command_window.x = Graphics.width - @command_window.width @gold_window.x = Graphics.width - @gold_window.width @status_window.x = 0 end end # Scene_Menu#==============================================================================# ■ Scene_Item#==============================================================================class Scene_Item < Scene_ItemBase #-------------------------------------------------------------------------- # alias method: start #-------------------------------------------------------------------------- alias scene_item_start_ame start def start scene_item_start_ame return if $imported["YEA-ItemMenu"] relocate_windows end #-------------------------------------------------------------------------- # new method: relocate_windows #-------------------------------------------------------------------------- def relocate_windows case Menu.help_window_location when 0 # Top @help_window.y = 0 @category_window.y = @help_window.height @item_window.y = @category_window.y + @category_window.height when 1 # Middle @category_window.y = 0 @help_window.y = @category_window.height @item_window.y = @help_window.y + @help_window.height else # Bottom @category_window.y = 0 @item_window.y = @category_window.height @help_window.y = @item_window.y + @item_window.height end if $imported["YEA-ItemMenu"] @types_window.y = @category_window.y @status_window.y = @category_window.y end end end # Scene_Item#==============================================================================# ■ Scene_Skill#==============================================================================class Scene_Skill < Scene_ItemBase #-------------------------------------------------------------------------- # alias method: start #-------------------------------------------------------------------------- alias scene_skill_start_ame start def start scene_skill_start_ame relocate_windows end #-------------------------------------------------------------------------- # new method: relocate_windows #-------------------------------------------------------------------------- def relocate_windows case Menu.help_window_location when 0 # Top @help_window.y = 0 @command_window.y = @help_window.height @status_window.y = @help_window.height @item_window.y = @status_window.y + @status_window.height when 1 # Middle @command_window.y = 0 @status_window.y = 0 @help_window.y = @status_window.y + @status_window.height @item_window.y = @help_window.y + @help_window.height else # Bottom @command_window.y = 0 @status_window.y = 0 @item_window.y = @status_window.y + @status_window.height @help_window.y = @item_window.y + @item_window.height end end end # Scene_Skill#==============================================================================# ■ Scene_Equip#==============================================================================class Scene_Equip < Scene_MenuBase #-------------------------------------------------------------------------- # alias method: start #-------------------------------------------------------------------------- alias scene_equip_start_ame start def start scene_equip_start_ame relocate_windows relocate_aee_windows end #-------------------------------------------------------------------------- # new method: relocate_windows #-------------------------------------------------------------------------- def relocate_windows return if $imported["YEA-AceEquipEngine"] case Menu.help_window_location when 0 # Top @help_window.y = 0 @status_window.y = @help_window.height @command_window.y = @help_window.height @slot_window.y = @command_window.y + @command_window.height @item_window.y = @slot_window.y + @slot_window.height when 1 # Middle @status_window.y = 0 @command_window.y = 0 @slot_window.y = @command_window.y + @command_window.height @help_window.y = @slot_window.y + @slot_window.height @item_window.y = @help_window.y + @help_window.height else # Bottom @status_window.y = 0 @command_window.y = 0 @slot_window.y = @command_window.y + @command_window.height @item_window.y = @slot_window.y + @slot_window.height @help_window.y = @item_window.y + @item_window.height end end #-------------------------------------------------------------------------- # new method: relocate_aee_windows #-------------------------------------------------------------------------- def relocate_aee_windows return unless $imported["YEA-AceEquipEngine"] case Menu.help_window_location when 0 # Top @help_window.y = 0 @command_window.y = @help_window.height @slot_window.y = @command_window.y + @command_window.height when 1 # Middle @command_window.y = 0 @help_window.y = @command_window.height @slot_window.y = @help_window.y + @help_window.height else # Bottom @command_window.y = 0 @slot_window.y = @command_window.height @help_window.y = @slot_window.y + @slot_window.height end @actor_window.y = @command_window.y @item_window.y = @slot_window.y @status_window.y = @slot_window.y end end # Scene_Equip#==============================================================================# ■ Scene_Menu#==============================================================================class Scene_Menu < Scene_MenuBase #-------------------------------------------------------------------------- # alias method: create_command_window #-------------------------------------------------------------------------- alias scene_menu_create_command_window_ame create_command_window def create_command_window scene_menu_create_command_window_ame process_common_event_commands process_custom_commands end #-------------------------------------------------------------------------- # new method: process_common_event_commands #-------------------------------------------------------------------------- def process_common_event_commands for command in YEA::MENU::COMMANDS next unless YEA::MENU::COMMON_EVENT_COMMANDS.include?(command) @command_window.set_handler(command, method🙂command_common_event)) end end #-------------------------------------------------------------------------- # new method: command_common_event #-------------------------------------------------------------------------- def command_common_event event_id = @command_window.current_ext return return_scene if event_id.nil? return return_scene if $data_common_events[event_id].nil? $game_temp.reserve_common_event(event_id) return_scene end #-------------------------------------------------------------------------- # new method: process_custom_commands #-------------------------------------------------------------------------- def process_custom_commands for command in YEA::MENU::COMMANDS next unless YEA::MENU::CUSTOM_COMMANDS.include?(command) called_method = YEA::MENU::CUSTOM_COMMANDS[command][3] @command_window.set_handler(command, method(called_method)) end end #-------------------------------------------------------------------------- # LEARN SKILLS #-------------------------------------------------------------------------- def learn_skills SceneManager.call(Scene_LearnSkill) end #-------------------------------------------------------------------------- # STATE VIEWER #-------------------------------------------------------------------------- def state_list SceneManager.call(Scene_StateView) end #-------------------------------------------------------------------------- # BESTIARY #-------------------------------------------------------------------------- def monster_book SceneManager.call(Scene_Bestiary) end #-------------------------------------------------------------------------- # MUSIC ROOM #-------------------------------------------------------------------------- def music_room SceneManager.call(Scene_Music_Box) end #-------------------------------------------------------------------------- # PICTURE GALLERY #-------------------------------------------------------------------------- def pic_gallery SceneManager.call(Scene_Picture_Gallery) end #-------------------------------------------------------------------------- # new method: command_debug #-------------------------------------------------------------------------- def command_debug SceneManager.call(Scene_Debug) end #-------------------------------------------------------------------------- # new method: command_shop #-------------------------------------------------------------------------- def command_shop goods = [] SceneManager.call(Scene_Shop) SceneManager.scene.prepare(goods, false) end #-------------------------------------------------------------------------- # new method: command_totori #-------------------------------------------------------------------------- def command_totori return unless $imported['KRX-AlchemicSynthesis'] SceneManager.call(Scene_Alchemy) end end # Scene_Menu#==============================================================================# # ▼ End of File# #==============================================================================
I've put $game_actors[1].mhp / 10 and it works perfectly - it takes first actor's max hp as a width and it's automatically refreshed after changing max hp.

(Using life up works perfectly - the gauge increases its size after each life up used on actor 1)

I thought it will be kinda easy process, since it worked with actor 1, but I see it's very very very complicated...

I want to use that as a replacement of drawing gauges.

Original thread: https://forums.rpgmakerweb.com/threads/ruby-rgssx-questions-that-dont-deserve-their-own-thread.150/