Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Loading the map name the game was saved on from a file
Resource Dragon
post Feb 9 2012, 03:11 PM
Post #1


Dragon has RAWR. So... RAWR.
Group Icon

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


__________________________
click me ->Signup for Digital Hijinks!<- click me
Go to the top of the page
 
+Quote Post
   
The Law G14
post Feb 9 2012, 04:13 PM
Post #2


Scripter FTW
Group Icon

Group: Local Mod
Posts: 1,348
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 smile.gif


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 ***
#
#==============================================================================




__________________________

To put in sig, copy this link:
CODE
[url="http://www.rpgrevolution.com/forums/index.php?showtopic=51540"][img]http://img40.imageshack.us/img40/6504/conceptthelawbanner.png[/img][/url]


Sig Stuff


"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

My Project Thread: Gai's Hunters


Go to the top of the page
 
+Quote Post
   
ForeverZer0
post Feb 9 2012, 06:05 PM
Post #3


Level 2
Group Icon

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

#===============================================================================
# * Game_Map
#===============================================================================

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
Go to the top of the page
 
+Quote Post
   
Resource Dragon
post Feb 9 2012, 11:29 PM
Post #4


Dragon has RAWR. So... RAWR.
Group Icon

Group: Local Mod
Posts: 984
Type: Developer
RM Skill: Masterful
Rev Points: 95




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. biggrin.gif 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,



This post has been edited by Resource Dragon: Feb 9 2012, 11:29 PM


__________________________
click me ->Signup for Digital Hijinks!<- click me
Go to the top of the page
 
+Quote Post
   
Resource Dragon
post Feb 12 2012, 03:59 PM
Post #5


Dragon has RAWR. So... RAWR.
Group Icon

Group: Local Mod
Posts: 984
Type: Developer
RM Skill: Masterful
Rev Points: 95




Eh, i'm having trouble getting either script to work with what i'm doing.

The command window;
window

CODE

    def select_save
    $game_system.se_play($data_system.decision_se)
    @command_window.active = false
    

    ary = [' NO DATA ']
    ary.push(' NO DATA ')
    ary.push(' NO DATA ')
    ary.push(' NO DATA ')
    ary.push(' NO DATA ')
    
    @save_select = Window_Command.new(81,
        ary,
        FE_Config::SCREEN_WIDTH/2 - 50,
        FE_Config::SCREEN_HEIGHT - (9 + ary.length * 16))
    if Input.trigger?(Input::B)
      @save_select.dispose
      end
    end


doing this;

ary.push($game_variables[Customization::MAP_VARIABLE], $game_variables[Customization::PLAYTIME_VARIABLE])

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.

This post has been edited by Resource Dragon: Feb 12 2012, 04:24 PM


__________________________
click me ->Signup for Digital Hijinks!<- click me
Go to the top of the page
 
+Quote Post
   
Resource Dragon
post Feb 16 2012, 11:14 AM
Post #6


Dragon has RAWR. So... RAWR.
Group Icon

Group: Local Mod
Posts: 984
Type: Developer
RM Skill: Masterful
Rev Points: 95




BUMPBUMPBUMPBUMPBUMP


__________________________
click me ->Signup for Digital Hijinks!<- click me
Go to the top of the page
 
+Quote Post
   
Jens of Zanicuud
post Feb 16 2012, 11:57 AM
Post #7


Dark Jentleman
Group Icon

Group: Local Mod
Posts: 916
Type: Scripter
RM Skill: Skilled
Rev Points: 120




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

This post has been edited by Jens of Zanicuud: Feb 16 2012, 12:01 PM


__________________________
"Thorns are the rose's sweetest essence..."
-Jens of Zanicuud


Games I'm working on:
>

official website: TryAdIne eFfeCt

>

Games I worked on (mainly as a scripter):
>
(Warning: it's a 3rr3's project and it's in Italian!)


Awards

Go to the top of the page
 
+Quote Post
   
Resource Dragon
post Feb 21 2012, 05:39 PM
Post #8


Dragon has RAWR. So... RAWR.
Group Icon

Group: Local Mod
Posts: 984
Type: Developer
RM Skill: Masterful
Rev Points: 95




Save reader script? I'm not finding it through google.


__________________________
click me ->Signup for Digital Hijinks!<- click me
Go to the top of the page
 
+Quote Post
   
ForeverZer0
post Feb 21 2012, 05:56 PM
Post #9


Level 2
Group Icon

Group: Member
Posts: 26
Type: Scripter
RM Skill: Masterful




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.
Go to the top of the page
 
+Quote Post
   
Resource Dragon
post Feb 24 2012, 09:40 AM
Post #10


Dragon has RAWR. So... RAWR.
Group Icon

Group: Local Mod
Posts: 984
Type: Developer
RM Skill: Masterful
Rev Points: 95




OH. ohmy.gif




lol, I am such an idiot. Sorry about that zer0. XD


__________________________
click me ->Signup for Digital Hijinks!<- click me
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 07:50 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker