Code:
#===============================================================================
# * Edit & Play
#-------------------------------------------------------------------------------
# - Version: 2.1
# - Date : 14 / 08 / 2011
# - Author : .:Fênix:.
# - MSN : bmotamer@hotmail.com
#-------------------------------------------------------------------------------
# - Description:
# Let you edit and play your game at the same time
#-------------------------------------------------------------------------------
# - Compability:
# RPG Maker XP and RPG Maker VX
#===============================================================================
module Edit_and_Play
# Activate the script? (true / false)
Activate = true
# Key which updates the game
Update_Key = Input::ALT
# Data files that won't be reloaded
File_Exclude = []
# Scripts that won't be reloaded
Scripts_Exclude = ["Edit & Play", "Main"]
end
$VX ||= defined?(Graphics.wait)
if ((Edit_and_Play::Activate) && !(File.file?("Game.rgss#{$VX ? '2a' : 'ad'}")))
char = $VX ? "v" : "x"
old_file = "Data/BT_Actors.r#{char}data"
new_file = "Data/BT_Actors2.r#{char}data"
if ($TEST || $DEBUG)
File.rename(old_file, new_file) if ($BTEST)
Thread.new {system("Game.exe")}
exit
else
$TEST = $DEBUG = true
if (File.file?(new_file))
File.rename(new_file, old_file)
$BTEST = true
end
end
unless ($VX)
class Scene_Battle
alias :edit_and_play_1 :main unless ($@)
def main
edit_and_play_1
$scene = Scene_Battle.new if ($BTEST)
end
end
end
class << Input
alias :edit_and_play_2 :update unless ($@)
def update
if (trigger?(Edit_and_Play::Update_Key))
for file in (Dir.entries("Data") - [".", "..", *Edit_and_Play::File_Exclude])
next if (file.include?("Map"))
basename = File.basename(file, ".*").downcase!
if (basename == "scripts")
($VX ? Cache : RPG::Cache).clear
for data in load_data("Data/#{file}")
next if (Edit_and_Play::Scripts_Exclude.include?(data[1]))
eval(Zlib::Inflate.inflate(data[2]))
end
$game_map.setup($game_map.map_id) if ($game_map != nil && $game_map.map_id != 0)
$scene = $scene.class.new
else
eval("$data_#{basename} = load_data('Data/#{file}')")
end
end
end
edit_and_play_2
end
end
end