Group: Local Mod
Posts: 984
Type: Developer
RM Skill: Masterful
Rev Points: 95
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.
This post has been edited by Resource Dragon: Feb 9 2012, 03:23 PM
Group: Local Mod
Posts: 1,346
Type: Scripter
RM Skill: Skilled
Rev Points: 5
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 *** # #==============================================================================
"When you first come, no one knows you. When help them out, they all know you. When you leave, they all love you. When you come back, they've already forgotten you." -- copy into your sig if you think this quote speaks true!
If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others. -Exiled One
Group: Member
Posts: 26
Type: Scripter
RM Skill: Masterful
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
This post has been edited by ForeverZer0: Feb 9 2012, 06:06 PM