Jump to content
Sign in to follow this  
SpuddyGoggles

Actor Name On File Select

Recommended Posts

I'm very new to scripting in Ace and Ruby in general (which I think is a given.)

Currently I'm attempting to have it so the file select screen displays the first actor's name rather than the default file name.

I thought that something along the lines of 

  def draw_actorname(x, y, width, line_height)
    header = DataManager.load_header(@file_index)
    if header.nil?
      draw_text(x, y, width, line_height, "NEW")
    else
      draw_text(x, y, width, line_height, $game_party.members[0].name)
    end
  end

would be sufficient. However the result is unfortunately a blank space where the name should be.

Any help would be appreciated.

Capture1.PNG

Share this post


Link to post
Share on other sites
Posted (edited)

I'm somewhat confused, because for me it just crashes when I put it that way. I imagined it will draw whatever leader was loaded in the last game session - so;

- crash when booting the game and selecting load because the party has not been setup yet

- draw current leader's name when opening save/load in-game, keep drawing the same name even after returning to title screen (because all data still remains until it's reset by "new game" or overwritten when loading a save file)

...but it just crashes claiming $game_party doesn't exist... eh. maybe I'm overlooking something because I'm tired.

Well either way, you'll need to add more data into save file's header and then refer to it. Calling $game_party will refer to current/last game session's data, not savefile's.

 

Paste this piece of code in the materials

module DataManager
  #--------------------------------------------------------------------------
  # * !overwrite: Create Save Header
  #--------------------------------------------------------------------------
  def self.make_save_header
    header = {}
    header[:characters] = $game_party.characters_for_savefile
    header[:playtime_s] = $game_system.playtime_s
    #===[ Custom ]===========================================================
    header[:leader_name] = $game_party.leader.name
    
    #========================================================================
    header
  end
end

 

This is code from DataManager - by default it only stores sprites of the characters (which contains filename and index) and playtime. This piece of code overwrites that method and adds more data into header. I separated defaults from additions for your convenience, better don't edit anything outside the "custom" block, otherwise things may go brrrr.

 

I've added a new header that stores leader's name upon saving.

Then, to read that header, use:

draw_text(x, y, width, line_height, header[:leader_name])

 

Be careful if you'd be planning to add more headers though, if you'll mistype something or put an incorrect variable and then try to save the game in the save menu, it will fail to do so, which will result in the savefile being removed instead. Keep it in mind if you'd be having some precious saves and then decide to toy with their headers.

Edited by Rikifive
  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

I should've thought to add a new header to the data manager. Thanks for the script though there seems to be an error that occurs after I try to use it.

Capture2.PNG

To make things clear, I added the def to Window_SaveFile to 

(yes i know that editing the default scripts isnt ever a good idea, but ive found that attempting to make my own scripts in main that directly overwrite existing scripts is puzzling and mildly irritating.)

Edited by SpuddyGoggles

Share this post


Link to post
Share on other sites

That probably had to be a minor derp in your code I assume? Glad you got it working in the end. 🙂

9 hours ago, SpuddyGoggles said:

To make things clear, I added the def to Window_SaveFile to 

(yes i know that editing the default scripts isnt ever a good idea, but ive found that attempting to make my own scripts in main that directly overwrite existing scripts is puzzling and mildly irritating.)

To be honest it depends. It is not a bad idea if you know what you are doing. It's all clearer to work with if you're just modifying the defaults directly, while aliasing/overwritting in new script slots is indeed irritating, because a single thing is all over the place.

I'd say it's not recommended because the majority of RM users don't know how to code and are unable to word their issues precisely. They install a 3rd party script and then be like "help my game crashes" and it's much more confusing to pinpoint the issue if it turns out, that they tinkered with the defaults without telling you that they did so. Having modifications in separate slots makes it easier to eventually undo the changes or adjust something. Should something break, just delete the adjustment and you're back in game, but if the defaults are changed, chances are beginners will get stuck struggling to restore their game to playable state.

Generally, if you're enjoying coding on your own and don't plan to flood your game with random 3rd party scripts (and just panic when the game crashes), you should be fine. 😉

 

You're welcome. 😄

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted