Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ■ Event Command Skip by OneEyedEagle (http://oneeyedeagle.lofter.com/)
- # License - MIT License: http://opensource.org/licenses/mit-license.php
- #==============================================================================
- $imported ||= {}
- $imported["EAGLE-EventCommandSkip"] = true
- #==============================================================================
- # - 2020.7.26.19 Optimized
- #==============================================================================
- # - Script that makes use of labels and adds event command SKIP
- #--------------------------------------------------------------------------
- # - New label is added before the command to start skip | SKIP ,
- # New label is added after the end of command to skip | SKIPEND ,
- # When a key is pressed during a command the process between SKIP and SKIPEND,
- # the commands can be skipped.
- #
- # - Example:
- # |- Label:SKIP
- # |- Show Text:Statement1
- # |- Show Balloon Icon:Exclamation
- # |- Show Text:Statement2
- # |- Label:SKIPEND
- # |- Show Text:Statement3
- #
- # Show Text Statement1, Surprise, Text Statement2, and Text Statement3:
- # If Shift key is pressed on statement 1, then command between is skipped.
- # Text Statement3 is still shown.
- #
- # - Adds a label to SKIPTHEN in front of command when a skip is used.
- # If skipped, the command between SKIPTHEN and SKIPEND are used.
- # If not skipped, the instructions between are not executed.
- #
- # - Example:
- # |- Label:SKIP
- # |- Show Text:Statement1
- # |- Show Text:Statement2
- # |- Label:SKIPTHEN
- # |- Show Text:Statement3
- # |- Label:SKIPEND
- # |- Show Text:Statement4
- #
- # Show Text Statement 1, Statement 2, and Statement 4 are shown in order.
- # If Shift key is pressed on statement 1.
- # Skipped Statement2 however continues Statement3, and to Statement4.
- #
- #==============================================================================
- module COMMAND_SKIP
- #--------------------------------------------------------------------------
- # ● 【Constant】 Skip label at the start (case sensitive)
- #--------------------------------------------------------------------------
- LABEL_SKIP = "SKIP"
- #--------------------------------------------------------------------------
- # ● 【Constant】 Label used when skipping contents to a point (case sensitive)
- #--------------------------------------------------------------------------
- LABEL_THEN = "SKIPTHEN"
- #--------------------------------------------------------------------------
- # ● 【Constant】 Skips to the end of the label if no SKIPTHEN (case sensitive)
- #--------------------------------------------------------------------------
- LABEL_END = "SKIPEND"
- #--------------------------------------------------------------------------
- # ● Key to skip
- #--------------------------------------------------------------------------
- def self.trigger?
- Input.trigger?(:A) || @need_skip
- end
- #--------------------------------------------------------------------------
- # ● Set up a text prompt
- #--------------------------------------------------------------------------
- def self.set_skip_hint(sprite)
- text = "Press Shift to skip"
- w = 16 * 9
- sprite.bitmap = Bitmap.new(w, 18)
- sprite.bitmap.font.size = 18
- sprite.bitmap.fill_rect(0,17,w,1, Color.new(255,255,255,220))
- sprite.bitmap.draw_text(0,1,sprite.width,sprite.height,text, 1)
- sprite.x = 15
- sprite.y = 15
- end
- #--------------------------------------------------------------------------
- # ● class self
- #--------------------------------------------------------------------------
- class << self
- attr_reader :sprite_hint
- end
- def self.init_hint
- if @hint_show_count.nil?
- @sprite_hint.dispose if @sprite_hint
- @sprite_hint = Sprite.new
- set_skip_hint(@sprite_hint)
- @sprite_hint.visible = false
- end
- end
- def self.show_hint
- @sprite_hint.visible = true
- @need_skip = false
- end
- def self.hide_hint
- @sprite_hint.visible = false
- @need_skip = nil
- end
- #--------------------------------------------------------------------------
- # ● Self skip?
- #--------------------------------------------------------------------------
- def self.skippable?
- @need_skip != nil
- end
- #--------------------------------------------------------------------------
- # ● Skip
- #--------------------------------------------------------------------------
- @need_skip = nil
- def self.call
- @need_skip = true
- end
- end
- #=============================================================================
- # ○ Game_Interpreter
- #=============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ● Skip run
- #--------------------------------------------------------------------------
- alias eagle_skip_run run
- def run
- COMMAND_SKIP.init_hint
- @eagle_skip_begin_i = nil # Record command start position of skip label.
- eagle_skip_run
- end
- #--------------------------------------------------------------------------
- # ● Skip update
- #--------------------------------------------------------------------------
- alias eagle_skip_update update
- def update
- eagle_skip_update
- eagle_process_skip if @eagle_skip_begin_i && COMMAND_SKIP.trigger?
- end
- #--------------------------------------------------------------------------
- # ● Skip command
- #--------------------------------------------------------------------------
- alias eagle_skip_command_118 command_118
- def command_118
- if @params[0] == COMMAND_SKIP::LABEL_SKIP
- COMMAND_SKIP.show_hint
- @eagle_skip_begin_i = @index
- elsif @eagle_skip_begin_i && @params[0] == COMMAND_SKIP::LABEL_THEN
- eagle_goto_label(COMMAND_SKIP::LABEL_END)
- COMMAND_SKIP.hide_hint
- @eagle_skip_begin_i = nil
- elsif @params[0] == COMMAND_SKIP::LABEL_END
- COMMAND_SKIP.hide_hint
- end
- eagle_skip_command_118
- end
- #--------------------------------------------------------------------------
- # ● Jump label
- #--------------------------------------------------------------------------
- def eagle_goto_label(label_name, i_begin = @index, i_end = @list.size-1)
- i = i_begin
- while i <= i_end
- if @list[i].code == 118 && @list[i].parameters[0] == label_name
- @index = i
- return true
- end
- i += 1
- end
- return false
- end
- #--------------------------------------------------------------------------
- # ● Process skip
- #--------------------------------------------------------------------------
- def eagle_process_skip
- @eagle_skip_begin_i = nil
- if !eagle_goto_label(COMMAND_SKIP::LABEL_THEN)
- eagle_goto_label(COMMAND_SKIP::LABEL_END)
- end
- COMMAND_SKIP.hide_hint
- if $imported["EAGLE-MessageEX"]
- window = SceneManager.scene.message_window
- window.force_close if window.open?
- end
- if $imported["EAGLE-AnimEX"]
- ANIM_EX.all_chara_sprites.each { |s| s.stop_animation }
- ANIM_EX.stop_all
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement