Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Question about player input

Set the event that controls your cutscene to "autorun". This should enable "enter" to dismiss the text windows, but not allow the player to move during the scene.
If you're keeping the player on the same map after the cutscene, make sure you terminate the autorun with a self-switch, and an additional event page.

Be Well
 
Add this code in the Script Editor anywhere.

Code:
#==============================================================================
# ** Input
#==============================================================================

module Input
  #------------------------------------------------------------------------
  # * Disabled Keys
  #------------------------------------------------------------------------
  @disabled_keys  = []
  @disabled_timer = {}
  class << self
    #------------------------------------------------------------------------
    # * Alias Listings
    #------------------------------------------------------------------------
    unless self.method_defined?(:seph_disabledkeys_input_update)
      alias_method :seph_disabledkeys_input_update,   :update
      alias_method :seph_disabledkeys_input_press?,   :press?
      alias_method :seph_disabledkeys_input_trigger?, :trigger?
      alias_method :seph_disabledkeys_input_repeat?,  :repeat?
      alias_method :seph_disabledkeys_input_dir4,     :dir4
      alias_method :seph_disabledkeys_input_dir8,     :dir8
    end
    #------------------------------------------------------------------------
    # * Name      : Disable Key
    #   Info      : Disables Input Constant from being read
    #   Author    : SephirothSpawn
    #   Call Info : Constant defined in Input Module to be disabled
    #               Frames to be disabled (nil for infinite frames)
    #------------------------------------------------------------------------
    def disable_key(constant, frames = nil)
      # Add Key to Disabled List
      @disabled_keys << constant unless @disabled_keys.include?(constant)
      # Set Disabled Counter if non-nil
      @disabled_timer[constant] = frames unless frames.nil?
    end
    #------------------------------------------------------------------------
    # * Name      : Enable Key
    #   Info      : Enable Input Constant
    #   Author    : SephirothSpawn
    #   Call Info : Constant defined in Input Module to be enabled
    #------------------------------------------------------------------------
    def enable_key(constant)
      # Remove Constant From List
      @disabled_keys.delete(constant)
      # Set Nil Timer
      @disabled_timer[constant] = nil
    end
    #------------------------------------------------------------------------
    # * Frame Update
    #------------------------------------------------------------------------
    def update
      # Pass Through Timer List
      @disabled_timer.each do |key, timer|
        # Next if nil timer or key not-disabled
        next if timer.nil? || !@disabled_keys.include?(key)
        # If Greater than 0 Timer
        if timer > 0
          timer -= 1
          next
        end
        # Enable Key
        @disabled_keys.delete(key) if @disabled_keys.include?(key)
        # Set Timer to Nil
        @disabled_timer[key] = nil
      end
      # Original Update
      seph_disabledkeys_input_update
    end
    #------------------------------------------------------------------------
    # * Press? Test
    #------------------------------------------------------------------------
    def press?(constant)
      return @disabled_keys.include?(constant) ? 
        false : seph_disabledkeys_input_press?(constant)
    end
    #------------------------------------------------------------------------
    # * Trigger? Test
    #------------------------------------------------------------------------
    def trigger?(constant)
      return @disabled_keys.include?(constant) ? 
        false : seph_disabledkeys_input_trigger?(constant)
    end
    #------------------------------------------------------------------------
    # * Repeat? Test
    #------------------------------------------------------------------------
    def repeat?(constant)
      return @disabled_keys.include?(constant) ? 
        false : seph_disabledkeys_input_repeat?(constant)
    end
    #------------------------------------------------------------------------
    # * Dir4 Test
    #------------------------------------------------------------------------
    def dir4
      # Gets Original Direction Test
      dir = seph_disabledkeys_input_dir4
      # Return 0 if Direction Disabled
      if (dir == 2 && @disabled_keys.include?(DOWN))  ||
         (dir == 4 && @disabled_keys.include?(LEFT))  ||
         (dir == 6 && @disabled_keys.include?(RIGHT)) ||
         (dir == 8 && @disabled_keys.include?(UP))
        return 0
      end
      # Return Original Dir Test
      return dir
    end
    #------------------------------------------------------------------------
    # * Dir8 Test
    #------------------------------------------------------------------------
    def dir8
      # Gets Original Direction Test
      dir = seph_disabledkeys_input_dir8
      # Return 0 if Direction Disabled
      if (dir == 2 && @disabled_keys.include?(DOWN))  ||
         (dir == 4 && @disabled_keys.include?(LEFT))  ||
         (dir == 6 && @disabled_keys.include?(RIGHT)) ||
         (dir == 8 && @disabled_keys.include?(UP))    ||
         (dir == 1 && @disabled_keys.include?(DOWN)   && 
                      @disabled_keys.include?(LEFT))  ||
         (dir == 3 && @disabled_keys.include?(DOWN)   && 
                      @disabled_keys.include?(RIGHT)) ||
         (dir == 7 && @disabled_keys.include?(UP)     && 
                      @disabled_keys.include?(LEFT))  ||
         (dir == 9 && @disabled_keys.include?(UP)     && 
                      @disabled_keys.include?(RIGHT))
        return 0
      end
      # Return Original Dir Test
      return dir
    end
  end
end


Now, to disable your keys, use:
Code:
Input.disable_key(constant, frames)

# Replace constant with Input::UP, Input::DOWN, Input::LEFT, Input::RIGHT, :Input::Alt, etc.
# Replace frames with the number of frames to delay or nil, to delay until re-enabled.

To manually re-enable key
Code:
Input.enable_key(constant)


Say you wanted to disable all the directions, buttons, etc.

Code:
for c in [Input::DOWN, Input::LEFT, Input::RIGHT, Input::UP, Input::A, Input::B, Input::C, Input::L, Input::R, Input::X, Input::Y, Input::Z, Input::ALT, Input::CTRL, Input::SHIFT]
  Input.disable_key(c, frames)
end

Let me know if you need any help.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top