#------------------------------------------------------------------------------- # 文章内検索スクリプト for VXAce 製作者:奏ねこま(おとぶきねこま) #------------------------------------------------------------------------------- # マップイベント、コモンイベント、バトルイベントの「文章の表示」のテキスト内を # 検索し、ヒットしたイベントの情報をコンソール画面に表示します。 # # [ 使い方 ] # # AND検索したい単語を@and_keywordに指定してください。 # OR検索した単語を@or_keywordに指定してください。 # テストプレイを実行すると、検索結果がコンソール画面に表示されます。 # ※エディタメニューの「ゲーム(G)→コンソールの表示(C)」はONにしてください。 # # [ 利用規約 ] ................................................................. # 本スクリプトの利用者は、RPGツクールVXAceの正規ユーザーに限られます。 # 商用、非商用、ゲームの内容(年齢制限など)を問わず利用可能です。 # ゲームへの利用の際、報告や出典元の記載等は必須ではありません。 # 二次配布や転載、ソースコードURLやダウンロードURLへの直接リンクは禁止します。 # (スクリプトを利用したゲームに同梱する形での結果的な配布はOKです) # 不具合対応以外のサポートやリクエストは受け付けておりません。 # 本スクリプトにより生じたいかなる問題においても、一切の責任を負いかねます。 # [ 改訂履歴 ] ................................................................. # Version 1.01 2016/10/15 バトルイベントに対応 # Version 1.00 2016/10/05 初版 # -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ # Web Site: http://makonet.sakura.ne.jp/rpg_tkool/ # Twitter : https://twitter.com/koma_neko module MessageSearch # AND検索するキーワードを指定してください。 @and_keyword = ["検索語1", "検索語2"] # OR検索するキーワードを指定してください。 @or_keyword = ["検索語3", "検索語4"] # ユーザー設定ここまで def self.and_keyword return @and_keyword end def self.or_keyword return @or_keyword end def self.and_search(text) hit = false if (@and_keyword.length > 0) hit = @and_keyword.all?{|keyword| text.include?(keyword) } end return hit end def self.or_search(text) hit = false if (@or_keyword.length > 0) hit |= @or_keyword.any?{|keyword| text.include?(keyword) } end return hit end def self.forMapEvents mapinfo = load_data("Data/MapInfos.rvdata2") mapinfo.each{|mid, mdata| map = load_data(sprintf("Data/Map%03d.rvdata2", mid)) map.events.each{|eid, edata| edata.pages.each_index{|pid| text = "" hit = false edata.pages[pid].list.each{|command| if (command.code == 101) if (text.size > 0) hit = and_search(text) hit |= or_search(text) if (hit) printf("// %s[ID:%03d]->%s[ID:%03d]->Page.%d\n\n", mdata.name, mid, edata.name, eid, pid + 1) printf("%s\n\n", text) end end text = "" hit = false end if (command.code == 401) text += "\n" if (text.size > 0) text += command.parameters[0] end } if (text.size > 0) hit = and_search(text) hit |= or_search(text) if (hit) printf("// %s[ID:%03d]->%s[ID:%03d]->Page.%d\n\n", mdata.name, mid, edata.name, eid, pid + 1) printf("%s\n\n", text) end end } } } end def self.forCommonEvents events = load_data("Data/CommonEvents.rvdata2") events.each_index{|eid| if (eid > 0) text = "" hit = false events[eid].list.each{|command| if (command.code == 101) if (text.size > 0) hit = and_search(text) hit |= or_search(text) if (hit) printf("// %s[ID:%03d]\n\n", events[eid].name, eid) printf("%s\n\n", text) end end text = "" hit = false end if (command.code == 401) text += "\n" if (text.size > 0) text += command.parameters[0] end } if (text.size > 0) hit = and_search(text) hit |= or_search(text) if (hit) printf("// %s[ID:%03d]\n\n", events[eid].name, eid) printf("%s\n\n", text) end end end } end def self.forBattleEvents troops = load_data("Data/Troops.rvdata2") troops.each_index{|tid| if (tid > 0) troops[tid].pages.each_index{|pid| text = "" hit = false troops[tid].pages[pid].list.each{|command| if (command.code == 101) if (text.size > 0) hit = and_search(text) hit |= or_search(text) if (hit) printf("// %s[ID:%03d]->Page.%d\n\n", troops[tid].name, tid, pid + 1) printf("%s\n\n", text) end end text = "" hit = false end if (command.code == 401) text += "\n" if (text.size > 0) text += command.parameters[0] end } if (text.size > 0) hit = and_search(text) hit |= or_search(text) if (hit) printf("// %s[ID:%03d]->Page.%d\n\n", troops[tid].name, tid, pid + 1) printf("%s\n\n", text) end end } end } end end if $TEST printf("/// 文章内キーワード検索 ///\n\n") printf(" AND検索キーワード:") MessageSearch.and_keyword.each{|keyword| printf("%s ", keyword) } printf("\n") printf(" OR検索キーワード:") MessageSearch.or_keyword.each{|keyword| printf("%s ", keyword) } printf("\n\n") printf(" [マップイベント内検索] ----------------\n\n") MessageSearch.forMapEvents printf(" [コモンイベント内検索] ----------------\n\n") MessageSearch.forCommonEvents printf(" [バトルイベント内検索] ----------------\n\n") MessageSearch.forBattleEvents end