king-exit/Scripts/_.42.rb
2024-08-31 14:17:23 -05:00

118 lines
No EOL
4.5 KiB
Ruby
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

=begin
▼ セルフスイッチの自動OFF ver. 1.1
RPGツクールVXAce用スクリプト
制作 : 木星ペンギン
URL : http://woodpenguin.blog.fc2.com/
------------------------------------------------------------------------------
概要
□ 場所移動でマップが切り替わった時に、設定したセルフスイッチ(とセルフ変数)を
 自動的にOFFにします。
------------------------------------------------------------------------------
初期化するセルフスイッチ(変数)を直接指定する場合
・イベントコマンドのスクリプトで、↓のスクリプトを入れて実行すると
 そのマップ ID のセルフスイッチが OFF になります。
$game_self_switches.delete(マップID, セルフスイッチの配列)
・セルフ変数の場合は、↓のスクリプトでセルフ変数が 0 になります。
$game_variables.delete(マップID, 変数番号の配列)
=end
module Wooden
module AutoOFF
#//////////////////////////////////////////////////////////////////////////////
#
# 設定項目
#
#//////////////////////////////////////////////////////////////////////////////
#--------------------------------------------------------------------------
# ● OFF にするセルフスイッチの配列
#--------------------------------------------------------------------------
SelfSwitches = ["D"]
#--------------------------------------------------------------------------
# ● OFF にするセルフ変数の配列
# 当然ですが「セルフ変数の追加」スクリプトが入っていないと意味ありません。
#--------------------------------------------------------------------------
SelfVariables = []
#--------------------------------------------------------------------------
# ● セルフスイッチ自動 OFF の例外マップ
# 例:マップ ID 2 では、セルフスイッチの A だけを OFF に、
# マップ ID 3 では、セルフスイッチの B と C を OFF にしたい場合
#
# { 2 => ["A"],
# 3 => ["B", "C"] }
#
# と設定してください。
#--------------------------------------------------------------------------
Ex_SelfSwitches = {}
end
end
#//////////////////////////////////////////////////////////////////////////////
#
# 以降、変更する必要なし
#
#//////////////////////////////////////////////////////////////////////////////
#==============================================================================
# ■ Game_Variables
#==============================================================================
class Game_Variables
#--------------------------------------------------------------------------
# ● セルフ変数の削除
#--------------------------------------------------------------------------
def delete(map_id, keys)
return unless @self_variables
@self_variables.reject! {|key,| key[0] == map_id && keys.include?(key[2]) }
end
end
#==============================================================================
# ■ Game_SelfSwitches
#==============================================================================
class Game_SelfSwitches
#--------------------------------------------------------------------------
# ● セルフスイッチの削除
#--------------------------------------------------------------------------
def delete(map_id, keys)
@data.reject! {|key,| key[0] == map_id && keys.include?(key[2]) }
end
end
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● モジュール
#--------------------------------------------------------------------------
include Wooden
#--------------------------------------------------------------------------
# ◯ セットアップ
#--------------------------------------------------------------------------
alias _wooden_autooff_setup setup
def setup(map_id)
if @map_id != map_id
if AutoOFF::Ex_SelfSwitches.include?(@map_id)
$game_self_switches.delete(@map_id, AutoOFF::Ex_SelfSwitches[@map_id])
else
$game_self_switches.delete(@map_id, AutoOFF::SelfSwitches)
end
$game_variables.delete(@map_id, AutoOFF::SelfVariables)
end
_wooden_autooff_setup(map_id)
end
end