Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # Dynamic Script Menu v1.03 by Zetu
- #===============================================================================
- module Z
- module Menu
- SCRIPTS = [
- #/regex/, script call.
- [/item/i, %Q{$scene = Scene_Item.new}],
- [/skill/i, %Q{$next = "Scene_Skill.new(@status_window.index)"
- start_actor_selection}],
- [/equip/i, %Q{$next = "Scene_Equip.new(@status_window.index)"
- start_actor_selection}],
- [/status/i, %Q{$next = "Scene_Status.new(@status_window.index)"
- start_actor_selection}],
- [/save/i, %Q{$scene = Scene_File.new(true, false, false)}],
- [/end/i, %Q{$scene = Scene_End.new}],
- [/clear/i, %Q{@command_window.output.clear}],
- [/exit/i, %Q{$scene = Scene_Map.new}],
- [/quicksave\((.*)\)/i, %Q{i = $1.to_i
- Scene_File.new(true, false, false).force_save(i)
- @command_window.output.print(
- "game saved to slot \#{i}")}]
- ]
- end
- module Item
- SCRIPTS = [
- [/item/i, %Q{@command_window.output.print(
- "start_selection $game_party.item")
- activate_item_selection}],
- [/exit/i, %Q{return_scene}],
- [/next/i, %Q{next_actor}],
- [/prev/i, %Q{prev_actor}]
- ]
- end
- module Skill
- SCRIPTS = [
- [/skill/i, %Q{@command_window.output.print(
- "start_selection @actor.skill")
- activate_skill_selection}],
- [/exit/i, %Q{return_scene}],
- [/next/i, %Q{next_actor}],
- [/prev/i, %Q{prev_actor}]
- ]
- end
- module Equip
- SCRIPTS = [
- [/equip/i, %Q{@command_window.output.print(
- "start_selection @actor.equips")
- activate_equip_selection}],
- [/exit/i, %Q{return_scene}],
- [/next/i, %Q{next_actor}],
- [/prev/i, %Q{prev_actor}]
- ]
- end
- module Status
- SCRIPTS = [
- [/next/i, %Q{next_actor}],
- [/prev/i, %Q{prev_actor}],
- [/exit/i, %Q{return_scene}]
- ]
- end
- module General
- SCRIPTS = [
- [/[\$game_party\.]gold/i, %Q{@command_window.output.print(
- "$game_party.gold == \#{$game_party.gold}")}],
- [/(?:\$game_party|PARTY)[\.members](?: |\.)size/, %Q{@command_window.output.print(
- "$game_party.members.size == \#{$game_party.members.size}")}],
- [/calc (.*)/i, %Q{value = eval($1)
- @command_window.output.print("Result \#{value}")}]
- ]
- end
- end
- class Scene_Menu < Scene_Base
- alias zmenu_start start
- def start
- zmenu_start
- @status_window.x = 35
- @status_window.y = 0
- @gold_window.x = 640
- @status_window.opacity = 0
- end
- def create_command_window
- @command_window = Scriptletter.new(0, 424, 640)
- @command_window.create_output(6)
- end
- def update_command_selection
- if JetInput.trigger?(JetInput::ESCAPE)
- Sound.play_cancel
- $scene = Scene_Map.new
- elsif JetInput.trigger?(JetInput::RETURN)
- run_regexp(@command_window.text)
- end
- end
- def update
- super
- update_menu_background
- @gold_window.update
- @status_window.update
- @command_window.update
- if @status_window.active
- update_actor_selection
- else
- update_command_selection
- end
- end
- def update_actor_selection
- if JetInput.trigger?(JetInput::ESCAPE)
- Sound.play_cancel
- end_actor_selection
- elsif JetInput.trigger?(JetInput::RETURN)
- $game_party.last_actor_index = @status_window.index
- Sound.play_decision
- $scene = eval($next)
- end
- end
- def run_regexp(string)
- for param in Z::Menu::SCRIPTS + Z::General::SCRIPTS
- if string =~ param[0]
- eval(param[1])
- @command_window.clear
- return
- end
- end
- @command_window.output.print("No Command '#{@command_window.text}' found!")
- @command_window.clear
- end
- def start_actor_selection
- @command_window.active = false
- @status_window.active = true
- if $game_party.last_actor_index < @status_window.item_max
- @status_window.index = $game_party.last_actor_index
- else
- @status_window.index = 0
- end
- end
- end
- class Window_MenuStatus < Window_Selectable
- def initialize(x, y)
- super(x, y, 570, 304)
- refresh
- self.active = false
- self.index = -1
- @column_max = 2
- @spacing = 4
- refresh
- end
- def refresh
- self.contents.clear
- @item_max = $game_party.members.size
- for actor in $game_party.members
- rect = item_rect(actor.index)
- x = rect.x + 6; y = rect.y + 19
- draw_actor_face(actor, x+2, y-10, 92)
- draw_actor_name(actor, x + 100, y)
- draw_actor_class(actor, x + 100, y+WLH)
- draw_actor_level(actor, x+ 192, y + WLH*1)
- draw_actor_hp(actor, x+100, y + WLH * 2, 148)
- draw_actor_mp(actor, x+100, y + WLH * 3, 148)
- draw_actor_state(actor, x, y + WLH * 4 - 12)
- end
- end
- def update_cursor
- if @index < 0
- self.cursor_rect.empty
- elsif @index < @item_max or @index >= 100
- rect = item_rect(@index)
- self.cursor_rect.set(rect.x, rect.y, rect.width, rect.height)
- else
- self.cursor_rect.set(0, 0, contents.width, contents.height)
- end
- end
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- rect.width = self.contents.width / @column_max - @spacing
- rect.height = self.contents.height / (Game_Party::MAX_MEMBERS / @column_max) - @spacing
- rect.x = index % @column_max * (rect.width + 4) + @spacing/2
- rect.y = index / @column_max * (rect.height + 4) + @spacing/2
- return rect
- end
- end
- class Scene_Base
- def create_menu_background
- @menuback_sprite = Sprite.new
- @menuback_sprite.bitmap = $game_temp.background_bitmap
- @menuback_sprite.color.set(16, 16, 16, 255)
- update_menu_background
- end
- end
- class Scene_File < Scene_Base
- def force_save(index)
- Sound.play_decision
- file = File.open(@savefile_windows[index].filename, "wb")
- write_save_data(file)
- file.close
- end
- end
- class Scene_Status < Scene_Base
- alias zstatus_start start unless $@
- def start
- zstatus_start
- @status_window.opacity = 0
- create_output
- end
- alias zstatus_terminate terminate unless $@
- def terminate
- zstatus_terminate
- @command_window.dispose
- end
- def update
- update_menu_background
- @status_window.update
- @command_window.update
- if JetInput.trigger?(JetInput::ESCAPE)
- Sound.play_cancel
- return_scene
- end
- update_command_selection
- super
- end
- def create_output
- @command_window = Scriptletter.new(0, 424, 640)
- @command_window.create_output(6)
- end
- def run_regexp(string)
- for param in Z::Status::SCRIPTS + Z::General::SCRIPTS
- if string =~ param[0]
- eval(param[1])
- @command_window.clear
- return
- end
- end
- @command_window.output.print("No Command '#{@command_window.text}' found!")
- @command_window.clear
- end
- def update_command_selection
- if JetInput.trigger?(JetInput::ESCAPE)
- Sound.play_cancel
- return_scene
- elsif JetInput.trigger?(JetInput::RETURN) and @command_window.text != ""
- run_regexp(@command_window.text)
- end
- end
- end
- class Scene_Skill < Scene_Base
- alias zskill_start start unless $@
- def start
- zskill_start
- @skill_window.height -= 96
- @skill_window.active = false
- @skill_window.opacity = 0
- @help_window.opacity = 0
- @status_window.opacity = 0
- create_output
- end
- alias zskill_terminate terminate unless $@
- def terminate
- zskill_terminate
- @command_window.dispose
- end
- alias zskill_update update unless $@
- def update
- @command_window.update
- zskill_update
- update_command_selection if @command_window.active
- end
- def update_skill_selection
- if JetInput.trigger?(JetInput::ESCAPE)
- Sound.play_cancel
- return_command_selection
- elsif JetInput.trigger?(JetInput::RETURN)
- @skill = @skill_window.skill
- if @skill != nil
- @actor.last_skill_id = @skill.id
- end
- if @actor.skill_can_use?(@skill)
- Sound.play_decision
- determine_skill
- else
- Sound.play_buzzer
- end
- end
- end
- def activate_skill_selection
- @command_window.active = false
- @skill_window.active = true
- end
- def return_command_selection
- @command_window.active = true
- @skill_window.active = false
- end
- def create_output
- @command_window = Scriptletter.new(0, 424, 640)
- @command_window.create_output(3)
- end
- def run_regexp(string)
- for param in Z::Skill::SCRIPTS + Z::General::SCRIPTS
- if string =~ param[0]
- eval(param[1])
- @command_window.clear
- return
- end
- end
- @command_window.output.print("No Command '#{@command_window.text}' found!")
- @command_window.clear
- end
- def update_command_selection
- if JetInput.trigger?(JetInput::ESCAPE)
- Sound.play_cancel
- return_scene
- elsif JetInput.trigger?(JetInput::RETURN) and @command_window.text != ""
- run_regexp(@command_window.text)
- end
- end
- end
- #==============================================================================
- # ** Scene_Item
- #------------------------------------------------------------------------------
- # This class performs the item screen processing.
- #==============================================================================
- class Scene_Item < Scene_Base
- alias zitem_start start unless $@
- def start
- zitem_start
- @item_window.height -= 96
- @item_window.opacity = 0
- @help_window.opacity = 0
- @item_window.active = false
- create_output(3)
- end
- alias zitem_terminate terminate unless $@
- def terminate
- zitem_terminate
- @command_window.dispose
- end
- alias zitem_update update unless $@
- def update
- @command_window.update
- zitem_update
- update_command_selection if @command_window.active
- end
- def update_item_selection
- if JetInput.trigger?(JetInput::ESCAPE)
- Sound.play_cancel
- return_command_selection
- elsif JetInput.trigger?(JetInput::RETURN)
- @item = @item_window.item
- if @item != nil
- $game_party.last_item_id = @item.id
- end
- if $game_party.item_can_use?(@item)
- Sound.play_decision
- determine_item
- else
- Sound.play_buzzer
- end
- end
- end
- def return_command_selection
- @item_window.active = false
- @command_window.active = true
- end
- def activate_item_selection
- @item_window.active = true
- @command_window.active = false
- end
- def create_output(lines)
- @command_window = Scriptletter.new(0, 424, 640)
- @command_window.create_output(lines)
- end
- def run_regexp(string)
- for param in Z::Item::SCRIPTS + Z::General::SCRIPTS
- if string =~ param[0]
- eval(param[1])
- @command_window.clear
- return
- end
- end
- @command_window.output.print("No Command '#{@command_window.text}' found!")
- @command_window.clear
- end
- def update_command_selection
- if JetInput.trigger?(JetInput::ESCAPE)
- Sound.play_cancel
- return_scene
- elsif JetInput.trigger?(JetInput::RETURN) and @command_window.text != ""
- run_regexp(@command_window.text)
- end
- end
- end
- class Scene_Equip < Scene_Base
- alias zequip_start start unless $@
- def start
- zequip_start
- @equip_window.height -= 24
- @equip_window.opacity = 0
- @status_window.height -= 24
- @status_window.opacity = 0
- create_output(3)
- @equip_window.active = false
- end
- alias zequip_terminate terminate unless $@
- def terminate
- zequip_terminate
- end
- alias zequip_create_item_windows create_item_windows unless $@
- def create_item_windows
- zequip_create_item_windows
- for i in 0...EQUIP_TYPE_MAX
- @item_windows[i].opacity = 0
- @item_windows[i].y -= 24
- @item_windows[i].height -= 72
- end
- end
- alias zequip_update_status_window update_status_window unless $@
- def update_status_window
- return if @item_window.nil?
- zequip_update_status_window
- end
- def update_equip_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- return_command_selection
- elsif Input.trigger?(Input::R)
- Sound.play_cursor
- next_actor
- elsif Input.trigger?(Input::L)
- Sound.play_cursor
- prev_actor
- elsif Input.trigger?(Input::C)
- if @actor.fix_equipment
- Sound.play_buzzer
- else
- Sound.play_decision
- @equip_window.active = false
- @item_window.active = true
- @item_window.index = 0
- end
- end
- end
- alias zequip_update update unless $@
- def update
- @command_window.update
- zequip_update
- update_command_selection if @command_window.active
- end
- def return_command_selection
- @equip_window.active = false
- @command_window.active = true
- end
- def activate_equip_selection
- @equip_window.active = true
- @command_window.active = false
- end
- def create_output(lines)
- @command_window = Scriptletter.new(0, 424, 640)
- @command_window.create_output(lines)
- end
- def run_regexp(string)
- for param in Z::Equip::SCRIPTS + Z::General::SCRIPTS
- if string =~ param[0]
- eval(param[1])
- @command_window.clear
- return
- end
- end
- @command_window.output.print("No Command '#{@command_window.text}' found!")
- @command_window.clear
- end
- def update_command_selection
- if JetInput.trigger?(JetInput::ESCAPE)
- Sound.play_cancel
- return_scene
- elsif JetInput.trigger?(JetInput::RETURN) and @command_window.text != ""
- run_regexp(@command_window.text)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment