Simple Self Variables

Self Variables
Version: 1.00


Introduction

This Script allows u to use Variables for every single Event,
like the Self Switches

Features
  • Unlimited number of Variables
Demo

Demo

Script

Self Variables Spoiler
#==============================================================================
# Self Variables Script v. 1.00
# by Caldaron (15.09.2006)
#==============================================================================
class Game_SelfVariables
  #--------------------------------------------------------------------------
  def initialize
    @data = {}
  end
  #--------------------------------------------------------------------------
  def [](key)
    if @data[key] != nil
      return @data[key]
    else
      return 0
    end
  end
  #--------------------------------------------------------------------------
  def []=(key, value)
      @data[key] = value
  end
  #--------------------------------------------------------------------------
end
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  attr_accessor :key
  #--------------------------------------------------------------------------
  def key(event_id, variable_id=1)
    return [@map_id, event_id, variable_id]
  end
  #--------------------------------------------------------------------------
end
#==============================================================================
class Scene_Title
  #--------------------------------------------------------------------------
  alias self_new_game command_new_game
  #--------------------------------------------------------------------------
  def command_new_game
    $game_self_variables = Game_SelfVariables.new
    self_new_game
  end
  #--------------------------------------------------------------------------
end
#==============================================================================
class Scene_Save
  #--------------------------------------------------------------------------
  alias self_write write_save_data
  #--------------------------------------------------------------------------
  def write_save_data(file)
    self_write(file)
    Marshal.dump($game_self_variables, file)
  end
  #--------------------------------------------------------------------------
end
#==============================================================================
class Scene_Load
  #--------------------------------------------------------------------------
  alias self_read read_save_data
  #--------------------------------------------------------------------------
  def read_save_data(file)
    self_read(file)
    $game_self_variables     = Marshal.load(file)
  end
  #--------------------------------------------------------------------------
end
Expand to see the code.


Instructions

Put the Script above Main.
To use Self Variables:
$game_self_variables[$game_map.key(event_id, variable_id)] = 0
Expand to see the code.
event_id: if u want to choose the current event, use @event_id
variable_id: the variable u want to change, normally set 1, so u can leave it out

FAQ

No questions yet...

Incompatibility

Not known, but i guess with sandgolem's Self Variable Script

Credits and Thanks

Credits to me, sry to Sandgolem for this Thread (if the majority uses it)

Author's Notes

I know! that sandgolem has a Self Variable Script to, but for me it was too much text, so i decided to make one for myself, which i didn't want to withhold ;)
i guess a little friendly competition never hurts. lol
Quote:
sry to Sandgolem for this Thread (if the majority uses it)

No need to apologize. :)

I just thought it was weird seeing it earlier. That's actually one of my least popular scripts, probably for the same reasons you didn't like it, hopefully yours has better luck. :)

(And there's nothing wrong with competition, yours is quite a bit different in how it's used as well)
i can't figure out how to use this it keeps giving me a syntax error when i try to call the script with an event.
when i call the script "$game_self_variables[$game_map.key(@event_id, 1)] = 0" from an event i get a syntax error and the game closes.
I'm not sure what I'm doing wrong. :'(

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=9292