[VXAce] Adding actor levels to custom save menu

UncannyBoots

Veteran
Veteran
Joined
Feb 1, 2020
Messages
42
Reaction score
5
First Language
English
Primarily Uses
RMVXA
I don't know if this thread should go in script support or here. But I'm putting it here because I'm trying to modify a script. I don't have any errors, I just want to add to it.

So I have the script More Informative Saves by mjshi (https://forums.rpgmakerweb.com/index.php?threads/more-informative-saves.52246/) and I've customized it to my liking, but there's just one more thing I would like to add that the default script does not do. I'd like to add each actor's level on the save screen, and I'd like it so that it's called similarly to the face sprites or party sprites or equip sprites etc, to where you can easily modify the spacing, the x position, and the y position, and the levels are shown in the order of the party formation.

I have a vague idea how to do this, but I do not fully understand the syntax, I guess.

Let's take the def draw_face_characters as an example.

Code:
  def draw_face_characters(x, y, spacing)
    header = DataManager.load_header(@file_index)
    return unless header && header[:faces]
    header[:faces].each_with_index do |data, i|
      draw_face(data[0], data[1], x + i * (96 + spacing), y)
    end
  end

I would assume that the way I want to add the levels can be done somewhat similarly to that, as in you would write something like "*character level*.each_with_index do |data, i|". Substitute *character level* with whatever method would have to be called.
Then I think you would put a "draw_text" in the place of "draw_face"? But I'm confused as to what to add between the () of draw_text().
This is all I can gather and I don't know what the 'rules' are to do this, as I'm no programmer. So I would appreciate some help. Thank you
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,186
Reaction score
839
First Language
Hungarian
Primarily Uses
RMVXA
This would be the gist of it:
Code:
module LvlTxt
  
  Settings = {
    :x  => 100, # X position for the 1st actor
    :y  => 30,  # Y position for the 1st actor
    :w  => 20,  # Width reserved for the level text
    :h  => 24,  # Height reserved for the level text
    :al => 1,   # Alignment used for the level text
    :sp => 32,  # Horizontal spacing between each actor's level text
  }
  
end

class << DataManager

  alias add_lvls7418 make_save_header
  def make_save_header
    header = add_lvls7418
    header[:lvls] = $game_party.members.collect {|mem| mem.level }    
    return header
  end
  
end

class Window_SaveFile < Window_Base

  alias add_lvls8826 refresh
  def refresh
    add_lvls8826
    draw_lvls(LvlTxt::Settings)
  end
  
  def draw_lvls(dt)
    header = DataManager.load_header(@file_index)
    return unless header
    header[:lvls].each_with_index do |lvl, i|
      draw_text(dt[:x] + i * dt[:sp], dt[:y], dt[:w], dt[:h], lvl, dt[:al])
    end
  end
  
end
This must be placed below that script you linked.

Since the level data for the actors are not saved by default, the first thing to do is to add that data to the save header. That's what I did in the method in the DataManager class.
Once this is done, the saved data can be displayed in the savefile window.

The draw_text method takes the following arguments in this order:
1. X position of the text
2. Y position of the text
3. Width reserved for the text
4. Height reserved for the text
5. The text to draw
6. The alignment used for the text (0 - Left, 1 - Middle, 2 - Right)

You can see that I made a setting area in a separate module right at the start of that little script. The arguments used for the draw_text method will be from there (aside from the level text data itself).
Note that I have no idea where do you want to place these level texts, so I just entered some random X and Y values. Make sure to change that to suit your menu layout.

The extra calculation for the 1st argument (X position) will make sure that the level texts for each actors won't be drawn at the same place. It adds the specified spacing after every level text drawn.

That would be it in short. I would explain it in more details, but it's time for me to drop into horizontal position on my comfy bed and get some quality sleepy hours.
 

UncannyBoots

Veteran
Veteran
Joined
Feb 1, 2020
Messages
42
Reaction score
5
First Language
English
Primarily Uses
RMVXA
This would be the gist of it:
Code:
module LvlTxt
 
  Settings = {
    :x  => 100, # X position for the 1st actor
    :y  => 30,  # Y position for the 1st actor
    :w  => 20,  # Width reserved for the level text
    :h  => 24,  # Height reserved for the level text
    :al => 1,   # Alignment used for the level text
    :sp => 32,  # Horizontal spacing between each actor's level text
  }
 
end

class << DataManager

  alias add_lvls7418 make_save_header
  def make_save_header
    header = add_lvls7418
    header[:lvls] = $game_party.members.collect {|mem| mem.level }   
    return header
  end
 
end

class Window_SaveFile < Window_Base

  alias add_lvls8826 refresh
  def refresh
    add_lvls8826
    draw_lvls(LvlTxt::Settings)
  end
 
  def draw_lvls(dt)
    header = DataManager.load_header(@file_index)
    return unless header
    header[:lvls].each_with_index do |lvl, i|
      draw_text(dt[:x] + i * dt[:sp], dt[:y], dt[:w], dt[:h], lvl, dt[:al])
    end
  end
 
end
This must be placed below that script you linked.

Since the level data for the actors are not saved by default, the first thing to do is to add that data to the save header. That's what I did in the method in the DataManager class.
Once this is done, the saved data can be displayed in the savefile window.

The draw_text method takes the following arguments in this order:
1. X position of the text
2. Y position of the text
3. Width reserved for the text
4. Height reserved for the text
5. The text to draw
6. The alignment used for the text (0 - Left, 1 - Middle, 2 - Right)

You can see that I made a setting area in a separate module right at the start of that little script. The arguments used for the draw_text method will be from there (aside from the level text data itself).
Note that I have no idea where do you want to place these level texts, so I just entered some random X and Y values. Make sure to change that to suit your menu layout.

The extra calculation for the 1st argument (X position) will make sure that the level texts for each actors won't be drawn at the same place. It adds the specified spacing after every level text drawn.

That would be it in short. I would explain it in more details, but it's time for me to drop into horizontal position on my comfy bed and get some quality sleepy hours.
Wow, thanks so much!

I get an error though:
"line 36: NoMethodError occurred.
undefined method 'each_with_index' for nil:NilClass".

Does it work on your end and it's a script compatibility issue on my side, or is it a simple error that could be fixed?
EDIT: I tested on a default project, and it does seem to work... which is good and bad. Good because your script works great, but bad because now I have to figure out what the compatibility problem is :p
EDIT 2: Well I guess it was just a problem with the save file itself. I deleted the save and then made a new save, and it works!

Again, thank you for your time :)

(My internet is being extremely slow for some reason and I thought I had posted this, but it turns out it never posted. So those "edits" are not really edits I guess haha. But yeah it works now, so thank you)
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,910
Reaction score
643
First Language
English
Primarily Uses
RMVXA
Sixth actually already helped me out
That's why questions shouldn't be asked in multiple threads.
I know another member that did the same thing and asked a question 5 times in different threads.
All of this should have been put into one new thread under rgssx script support.
 

UncannyBoots

Veteran
Veteran
Joined
Feb 1, 2020
Messages
42
Reaction score
5
First Language
English
Primarily Uses
RMVXA
That's why questions shouldn't be asked in multiple threads.
I know another member that did the same thing and asked a question 5 times in different threads.
All of this should have been put into one new thread under rgssx script support.
Geez man I'm sorry. I asked in the original script thread without thinking too much about it, then realized the last post was 4 years old. You can't delete posts on this forum. I just forgot about it after that. Around 72 hours later after struggling with trying to do it myself I decided to make a support thread for help. I apologize.
 

Latest Threads

Latest Profile Posts

KenKrath wrote on RPGMakerWeb's profile.
Hi there!! I saw my Valentines Video placed in the contest. I'm wondering if I placed 3rd or 1st though because my video was shown first but my name is shown as the 3rd video. Thanks for the opportunity :)
I found a book about game localization. It costs R$708,00 on Amazon. ;_;
I really wish my game was far enough along for it to be actually playable beyond certain aspects. I think I've crafted a really fun battle system thanks to ATB, fighting game, and Boost point mechanics.
Play test of my current progress on Happy Camper
Cutscene Contest Winners have been announced!

Forum statistics

Threads
109,112
Messages
1,042,186
Members
141,608
Latest member
Sinthea
Top