Self Variables
Version: 1.00
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
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
# 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.
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 ;)