Jump to content
RavenBlueIndigo

Variable Store Script

Recommended Posts

I need a script that can store select variables so that they don't reset after dying. I need this because I am making a sequel to a game I made and released, and in the sequel, I am timing the cutscenes to voice acting and want to make it so that if you've seen the cutscene once, you have the option to skip it if you die soon after without saving, I want to do this by setting a variable at the end of each cutscene.

Share this post


Link to post
Share on other sites

I don't knew a script that will do this, but i think it's hard to make or not possible.

But you cold make it without scripts.

You could make, that if the player was killed after the cutscene the the screen will fade out and a picture of the game over screen will appear (only a picture not the real game over screen!!).

Then you activate recover all and activate a switch (you can name it 'game over' or so)  or change the number of the variable to 5. Then erease the game over picture and transfer the player back to the cutscene room and fadein the screen.

Cutscene event:

              -Add an new event page and set under conditions switch 'gameover' is on or variable game over is 5 or higher

              -add at the start of the second event page an show choises with Yes or no. then past the events on the first event page under 'if yes'. And the 'transfer player' under yes and no..

 

I hope i could help you.

Sry for my bad english :)

Share this post


Link to post
Share on other sites

Well, that's possible.

Maybe, can you give a shot to these codes?

# ------------------------------------------------
# Variable Store script
# ------------------------------------------------

  Stored_Variables_ID = [1,2,3,4,5]
# Record your variable ID here

# ------------------------------------------------
# Do not touch anything pass this line
# ------------------------------------------------
class << DataManager
  
  alias theo_savedvar_create_obj create_game_objects
  def create_game_objects
    theo_savedvar_create_obj
    load_variables
  end
  
  def load_variables
    save_variables unless variable_file_exist?
    load_saved_variables
    puts $game_variables[1]
  end
  
  def save_variables
    hash = {}
    Stored_Variables_ID.each do |id|
      hash[id] = $game_variables[id]
    end
    File.open(variable_filename, "wb") do |file|
      Marshal.dump(hash, file)
    end
  end
  
  def load_saved_variables
    hash = load_data(variable_filename)
    hash.each do |id,value|
      $game_variables.theo_savedvar(id, value)
    end
  end
  
  def variable_file_exist?
    FileTest.exist?(variable_filename)
  end
  
  def variable_filename
    return "Data/Variables.rvdata2"
  end
  
  alias theo_savedvar_load_game load_game
  def load_game(index)
    begin
      theo_savedvar_load_game(index)
      load_saved_variables
      return true
    rescue 
      return false
    end
  end
  
end

class Game_Variables
  
  alias :theo_savedvar :[]=
  def []=(variable_id, value)
    theo_savedvar(variable_id, value)
    if Stored_Variables_ID.include?(variable_id) && 
      DataManager.variable_file_exist?
      DataManager.save_variables
    end
  end
  
end

Just a quick script. I'm not quite sure anyway

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×