What, ho? Where did my Night Runner go? Please tell me, so I shall know! Was he taken, by friend, or foe?
I may go on from time to time, you may get sick of my dumb rhyme. but I will continue to rhyme for dime, my rhymes nefarious, awesome, sublime.
I need some help with my RGSS, it usually ends up in great big messes. to call the last map name from a file, or I may break down for quite awhile.
Thank you for your time and support, I sometimes sound like such a dork. Help with this problem would be quite swell, if you have questions, please do tell.
*Translation*
Yea, i'm trying to figure out how to load just the last map name the game was saved on from a file, and turn it into a string so it will show up correctly in the command box. Night Runner is my main man for help with RGSS, but he is unavailable at the time being. Need some help lol.
EDIT: I need to be able load the last map name, and the total game time, as well. lol.
The Law G14
Feb 9 2012, 04:13 PM
Hello, yo! Where did our Night Runner Go? I shall tell you, so you may know! He has taken a vacation for the Holidays Yo! (He’ll actually be back on February 16th)
I too may go on from time to time, but no I do not get sick of your rhyme. I too will continue with my rhyme for two dimes, my rhymes reprehensible, breathtaking, sublime.
I noticed you need some help with RGSS, I usually fix up great big messes. so you say you want to call the last map name from a file, so I will help so you may not break down for quite awhile.
Your welcome for my time and support, I sometimes attack problems like a fork. Help with a problem is coming here soon, just look below and salivate like a bafoon!
Anyway, since you’re poem was epic it’s required that I help xD lol Anyway, Im a bit confused though on your request, so you want the name of the map that was last saved on and total play time? Do you want it just stored in a variable? Well, anyway, I attempted to make something to see if this is what you’re looking for, instructions are at the top of the script
code
CODE
#============================================================================== # Title: Load Information # Version: 1.0 # Author: The Law G14 #==============================================================================
module Customization
#-------------------------------------------------------------------------- # * Game Variables Customization #-------------------------------------------------------------------------- # Map Name Variable - This variable is set by you to determine what # Control Variable will be storing the map name you saved on. MAP_VARIABLE = 1 # Play Time Variable - This variable is set by you to determine what # Control Variable will be storing the total play time at the time of saving PLAYTIME_VARIABLE = 2
end
#============================================================================== # ** Game_Map #------------------------------------------------------------------------------ # This class handles the map. It includes scrolling and passable determining # functions. Refer to "$game_map" for the instance of this class. #==============================================================================
class Game_Map #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :name # Name #-------------------------------------------------------------------------- # * Alias Listing #-------------------------------------------------------------------------- alias law_loadinfo_gamemap_setup setup #-------------------------------------------------------------------------- # * Setup # map_id : map ID #-------------------------------------------------------------------------- def setup(*args) # Run the original setup law_loadinfo_gamemap_setup(*args) # Load the name of the map @name = load_data("Data/MapInfos.rxdata")[@map_id].name end end
#============================================================================== # ** Scene_Load #------------------------------------------------------------------------------ # This class performs load screen processing. #==============================================================================
class Scene_Load < Scene_File #-------------------------------------------------------------------------- # * Alias Listing #-------------------------------------------------------------------------- alias law_loadinfo_sceneload_readsavedata read_save_data #-------------------------------------------------------------------------- # * Read Save Data # file : file object for reading (opened) #-------------------------------------------------------------------------- def read_save_data(file) # Call original method law_loadinfo_sceneload_readsavedata(file) # Store last visited map's name into variable $game_variables[Customization::MAP_VARIABLE] = $game_map.name.to_s # Gather Play Time frame_count = Marshal.load(file) total_sec = @frame_count / Graphics.frame_rate hour = @total_sec / 60 / 60 min = @total_sec / 60 % 60 sec = @total_sec % 60 $game_variables[Customization::PLAYTIME_VARIABLE] = sprintf("%02d:%02d:%02d", hour, min, sec) end end
#============================================================================== # # *** END OF SCRIPT *** # #==============================================================================
ForeverZer0
Feb 9 2012, 06:05 PM
This will work. It allows for checking basically anything you want from the save file easily. I added a couple methods for specifically checking the playtime and map name.
CODE
# Use like this: # # data = SaveReader.load("PATH_TO_FILE") # time_string = SaveReader.playtime(data.frames) # name = data.map.name # # #=============================================================================== # * SaveReader #===============================================================================
module SaveReader
#----------------------------------------------------------------------------- # * SaveFile # - Simple Struct to reference save file data through #----------------------------------------------------------------------------- SaveFile = Struct.new(:characters, :frames, :system, :switches, :variables, :self_switches, :screen, :actors, :party, :troop, :map, :player) #----------------------------------------------------------------------------- # * load # - Loads a save file into a SaveFile object and returns it #----------------------------------------------------------------------------- def self.load(save_path) file = File.open(save_path, 'rb') save_file = SaveFile.new save_file.characters = Marshal.load(file) save_file.frames = Marshal.load(file) save_file.system = Marshal.load(file) save_file.switches = Marshal.load(file) save_file.variables = Marshal.load(file) save_file.self_switches = Marshal.load(file) save_file.screen = Marshal.load(file) save_file.actors = Marshal.load(file) save_file.party = Marshal.load(file) save_file.troop = Marshal.load(file) save_file.map = Marshal.load(file) save_file.player = Marshal.load(file) file.close return save_file end #----------------------------------------------------------------------------- # * playtime # - Parses a frame count and returns it as a time string #----------------------------------------------------------------------------- def self.playtime(frames) total = frames / Graphics.frame_rate hour = total / 60 / 60 min = total / 60 % 60 sec = total % 60 text = sprintf("%02d:%02d:%02d", hour, min, sec) end end
class Game_Map #----------------------------------------------------------------------------- # * name # - Returns the name of a map, the current one by default # Call with a map_id argument to get that map's name #----------------------------------------------------------------------------- def name(map_id = @map_id) return load_data('Data/MapInfos.rxdata')[map_id].name end end
Resource Dragon
Feb 9 2012, 11:29 PM
Yea, I figured if it was stored to a variable I could probably just have it print the variable. I'll try it out and see if it works the way i'm hoping. Thanks for your guys' quick answers.
And yea, I thought the poem was cool too. I just wrote it, spur of the moment. lol.
Also, just for a lol,
Resource Dragon
Feb 12 2012, 03:59 PM
Eh, i'm having trouble getting either script to work with what i'm doing.
doesn't work, but relays to you at what i'm trying to accomplish. I also have five save slots, so it would have to load 5 seperate map names and 5 seperate game times. It would be nice if it wasnt stored to an in-game variable, but a script variable. :/
I'm hoping the end result would be something like;
Game Map Name 1 Game time 1
Game Map Name 2 Game Time 2
...etc.
I also tried to put it in a module, but that doesn't work either...
EDIT: also, I have the files named as 'one.rxdata', 'two.rxdata', etc.
Resource Dragon
Feb 16 2012, 11:14 AM
BUMPBUMPBUMPBUMPBUMP
Jens of Zanicuud
Feb 16 2012, 11:57 AM
What if you add these few lines below ary initialization:
CODE
time_ary = ["","","","",""] for i in 0...5 #check every save file file_name = "Save#{i+1}.rxdata" if FileTest.exist?(file_name) #load file file = SaveReader.load(file_name) #make map name data = load_data("Data/MapInfos.rxdata") map_name = data[file.map.map_id] #push element into the array ary[i] = (map_name) time_ary[i] = file.playtime(file.frames) end end
using ForeverZero SaveReader script?
result: two arrays: ary, which contains map names, time_ary, which contains files playtime.
Jens
Resource Dragon
Feb 21 2012, 05:39 PM
Save reader script? I'm not finding it through google.
ForeverZer0
Feb 21 2012, 05:56 PM
Maybe you should scroll up the page a little bit. I wrote and posted it specifically for this topic, it isn't posted anywhere else.
Resource Dragon
Feb 24 2012, 09:40 AM
OH.
lol, I am such an idiot. Sorry about that zer0. XD
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.