Zen Blood 70 Posted September 12, 2019 (edited) Hello! I was hoping to program a text line in my save files that indicates where the player is at when they save the game. I've created a global variable ($v_player_location) that is set as a string so I can change the labeled "location" on a whim without having to change the map names in the editor. The player interacts with an event, within that event I have $v_player_location set to whatever location name I want it to be, and then the game saves. The "player location" does indeed show on the save files, but the issue here is that the location for every save file is portrayed as the same string because it's reflecting what $v_player_location currently is, instead of what it was at the time of each individual save. I was able to make the save files show individual play times. def draw_playtime(x, y, width, align) header = DataManager.load_header(@file_index) return unless header draw_text(x, y, width, line_height, "play time: " + header[:playtime_s], 2) end As you can see, it uses the symbol :playtime_s It's been a while since I added the play time, so I'm not sure what "header" is referring to, whether its something I created or a system already in place within the RPGMVXA engine. Don't mind me, I'm half asleep. I've found that "header" is referring to the "def self.make_save_header" line within DataManager. I tried to turn the location into a symbol, too, that would initiate upon a new game and set when the player saves. def draw_location(x, y, width, align) draw_text(x, y, width, line_height, "location: " + contents[:plocation], 4) end This did not work. It seems as though I need to figure out how to tell the program I want to access :plocation within contents, but that one line alone can't do it. I probably have to do some version of the line "header = DataManager.load_header(@file_index)" to access :plocation, from what I can tell. Would anyone happen to have any ideas as to how I can grab the contents of a variable for each individual save and display it on the save files? Edit: Here's another piece of the puzzle that shows how the individual play times where achievable. It was also located in DataManager. Interestingly, it's referenced using "DataManager.load_header(@file_index)" instead of "DataManager.load_header_without_rescue(@file_index)". #-------------------------------------------------------------------------- # * Load Save Header (No Exception Processing) #-------------------------------------------------------------------------- def self.load_header_without_rescue(index) File.open(make_filename(index), "rb") do |file| return Marshal.load(file) end return nil end I had a feeling this would dig into the Marshal load/dump/ect; I'm not entirely sure where to go from here, but I'll keep plugging anyway at it. Another Edit: I read up on a similar question someone had, and a person offered a solution to add the variable under header. I was originally trying to place the variable under "contents". Supposedly, this was what would make the variable work. class << DataManager def self.create_game_objects orig_CGO #This works, I'm just not showing the rest of the script here. #MY OBJECTS $v_player_location = "" #blank at the beginning of the game end alias_method(:new_make_save_header, :make_save_header) def make_save_header header = new_make_save_header header[:plocation] = $v_player_location header end end #END CLASS class Window_SaveFile < Window_Base def draw_location(x, y, width, align) header = DataManager.load_header(@file_index) return unless header draw_text(x, y, width, line_height, "location: " + header[:plocation], 4) end end #END CLASS It doesn't, I'm getting an error "can't convert nil into string". This error goes away when I replace header[:plocation] in def draw_location with a string. So that's the issue here. It thinks :plocation is nil, even though I've at least given it a blank string and have it's string changed before a save file is made. Update: This error also goes away when I omit "location " + and keep header[:plocation]. This works well enough for me, but for future sake, I'd like to know why I can include "playtime: " + alongside header[:playtime_s], but not "location " + alongside header[:plocation]. Solution 1: If you're happy with just the variable showing without another string on the same line, this template should work for you. Spoiler class << DataManager #YOU SHOULD BE ABLE TO ALIAS THIS TOO, IF YOU'D LIKE TO KEEP THE SCRIPT SHORT def self.make_save_header header = {} header[:characters] = $game_party.characters_for_savefile header[:playtime_s] = $game_system.playtime_s header[:yourvariable] = $yourglobalvariable # <----- header end end #END CLASS class Window_SaveFile < Window_Base def draw_yourvariable(x, y, width, align) header = DataManager.load_header(@file_index) return unless header draw_text(x, y, width, line_height, header[:yourvariable], 4) end end #END CLASS Thank you for reading! Edited September 16, 2019 by Zen Blood Updating with a title change so people with the same issue can find the solution. Share this post Link to post Share on other sites