kyonides

Reforged is laughable
Regular
Joined
Nov 17, 2019
Messages
1,756
Reaction score
892
First Language
English
Primarily Uses
RMXP
GlobalValues XP

by Kyonides

Introduction

Once upon a weird time, there was a forumer that wanted to rewrite many saved games for no good reason.
What if there was a better solution?
Yeah, like a Global Save File! :D

My scriptlet will handle almost everything on its own except for one single thing, namely the Game Over screen.
You got to make the script call by hand so to say. :p

The Script

Code:
# * GlobalValues XP * #

#  Scripter : Kyonides Arkanthes
#  v0.3.0 - 2023-06-03

# This script creates a new Global Variable and stores values there for future
# use in all game sessions.

# It will update the battle result variables automatically if you are using
# a Battle System that is compatible enough with the Default BS.

# Stats like Wins, Escapes, Losses, Saves, and Loads are already
# updated by the script automatically!

# * Script Calls * #

# - Access Wins:
#  $global_data.wins
# - Access Escapes:
#  $global_data.escapes
# - Access Losses:
#  $global_data.losses
# - Access Total Saves:
#  $global_data.saves
# - Access Total Loads:
#  $global_data.loads
# - Access or Update Total Gameovers:
#  $global_data.gameovers
#  $global_data.gameover!
# - Access or Update the Switch:
#  $global_data.switch
#  $global_data.switch = true
#  $global_data.switch = false

# * Optional - No Need for You to use them! * #

# - Create or Load the new Global Variable
#  Global.load_file

# - Save Global Data at Any Moment
#  Global.save_file

module Global
  # PATH = "" means the Game's Root Directory (RD)
  # PATH = "Saves" means the Saves Directory at the RD
  PATH = ""
  FILENAME = "GlobalValues.rxdata"
  class Values
    def initialize
      @wins = 0
      @escapes = 0
      @losses = 0
      @saves = 0
      @loads = 0
      @gameovers = 0
      @switch = nil
    end

    def save_result(result)
      case result
      when 0
        @wins += 1
      when 1
        @escapes += 1
      when 2
        @losses += 1
      end
      Global.save_file
    end

    def saved!
      @saves += 1
      Global.save_file
    end

    def loaded!
      @loads += 1
      Global.save_file
    end

    def gameover!
      @gameovers += 1
      Global.save_file
    end
    attr_accessor :wins, :escapes, :losses
    attr_accessor :saves, :loads, :gameovers, :switch
  end

  extend self
  def filename
    if PATH.empty?
      FILENAME
    else
      PATH + "/" + FILENAME
    end
  end

  def save_file
    save_data($global_data, filename)
  end

  def load_file
    if File.exist?(filename)
      $global_data = load_data(filename)
    else
      $global_data = Global::Values.new
      save_file
    end
  end
  load_file
end

class Scene_Save
  alias :kyon_global_values_scn_sv_wsd :write_save_data
  def write_save_data(file)
    kyon_global_values_scn_sv_wsd(file)
    $global_data.saved!
  end
end

class Scene_Load
  alias :kyon_global_values_scn_ld_rsd :read_save_data
  def read_save_data(file)
    kyon_global_values_scn_ld_rsd(file)
    $global_data.loaded!
  end
end

class Scene_Battle
  alias :kyon_global_values_scn_btl_btl_end :battle_end
  def save_global_data(result)
    $global_data.save_result(result)
  end

  def battle_end(result)
    save_global_data(result)
    kyon_global_values_scn_btl_btl_end(result)
  end
end

Terms & Conditions

Free for use in any game, as long as you don't complain at all.
Include my nickname in your game credits.
That's it!
 

Latest Threads

Latest Posts

Latest Profile Posts

What does it say about you when a mushroom is your best friend?
If a game had a moral-choice system at the beginning 3 chapters where defeating an on-screen encounter grants a "-2" at the end of the level whereas evading it granted "+2" at the end of the chapter, and then each chapter also had a dialogue choice that'd give/take points depending on the answer the player gives, how many points would you expect to gain from the dialogue choices?
Dynamic.png

My next plugin will be:

DYNAMIC SWITCHES! (For RPG MAKER MZ)

What does this plugin allow?

Basically it allows you to create switches that work even though the game is closed.

Example of use:

You can make a system that you can only run a mini game once a day (or an event or whatever you want) and you have to wait 24 hours to play again.

I open thread here...
Brain: Hey! Let's draw something inspired by Tangela.
Result: Hartestant.png

Brain: What the hell man! That's it, I'm out!
Mockup thinghie for a turn based Tactics gameplay!
mockup.png

Forum statistics

Threads
134,797
Messages
1,250,749
Members
177,590
Latest member
MonoNSFWArt
Top