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.

Button Disable (Simple)

CERU

Member

I need a script that does not allow the player to press any buttons for a short period of time, so that they can't skip through the automatically closing text boxes I have set up. Is this do-able?

What I want seems fairly self explanatory to me, but if you have any questions please ask.
 
Some of the more popular Message systems have this feature buil;t into them.

I use ccoa's Universal Messasge System myself and there is multiple ways to do that wth her script. But I also know that Dubealex's AMS has that feature.

Which message system are you using?
 

CERU

Member

An outdated one.

I am aware and have upgraded to the new messaging system in a newer game, but I don't want to have to redo all of the dialogue in my game in order to achieve this.
 

CERU

Member

SephirothSpawn;204353 said:
I will create a little something that you can disable buttons from being recognized when you press the button. Just give me until tomorrow. Simple system.

When you press the button? You mean user input? I'm confused.

I want it to disable all button function when I call the script, and there has to be a way to deactivate the script.


hima;204349 said:
Please give me the message script, and I'll see what I can do. This shouldn't be difficult.

But I don't want all of the text to be non-skippable. I just want to delay button input for a short period of time.
 
What I mean is you tell the system to

a) Disable the Input Key lets say SHIFT
or
b) Disable the Input Key for CTRL for 25 frames

It will just modify the Input.trigger?, Input.repeat?, Input.press?, and Input.dir4 * 8, so that those keys will not be read as pressed, until the number of frames pass, or the key is re-enabled.

I didn't get time to finish this today. I was too lazy to take my laptop to work. I will do it before I pass out or at work tomorrow on my lunch.
 

CERU

Member

SephirothSpawn;204941 said:
What I mean is you tell the system to

a) Disable the Input Key lets say SHIFT
or
b) Disable the Input Key for CTRL for 25 frames

It will just modify the Input.trigger?, Input.repeat?, Input.press?, and Input.dir4 * 8, so that those keys will not be read as pressed, until the number of frames pass, or the key is re-enabled.

I didn't get time to finish this today. I was too lazy to take my laptop to work. I will do it before I pass out or at work tomorrow on my lunch.

Oh okay. Its fine, I'm just happy that I'm getting a script at all.
 
Sorry. here you are:

Code:
#==============================================================================
# ** Disabled Keys
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1
# 2007-05-15
# SDK Version 2.2
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1 ---------------------------------------------------- (2007-05-15)
#------------------------------------------------------------------------------
# * Description :
#
#   This script was designed to disable keys from being read as pressed. It
#   works for any constant in the Input module. You may disable a key until
#   it is re-enabled, or you can disable a key for a number of frames.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#------------------------------------------------------------------------------
# * Syntax :
#
#   Input.disable_key(<constant>)
#   Input.disable_key(<constant>, <frames>)
#    - <constant> : Any constant defined as a key in the module Input
#    - <frames>   : Number of frames until key is re-enabled
#
#   Input.enable_key(<constant>)
#    - <constant> : Any constant defined as a key in the module Input
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Disabled Keys', 'SephirothSpawn', 1, '2007-05-15')
SDK.check_requirements(2.2) 

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.enabled?('Disabled Keys')

#==============================================================================
# ** Input
#==============================================================================

module Input
  class << self
    #------------------------------------------------------------------------
    # * Disabled Keys
    #------------------------------------------------------------------------
    @disabled_keys  = []
    @disabled_timer = {}
    #------------------------------------------------------------------------
    # * Alias Listings
    #------------------------------------------------------------------------
    if @seph_disabledkeys_stack.nil?
      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
      @seph_disabledkeys_stack = true
    end
    #------------------------------------------------------------------------
    # * Disable Key
    #------------------------------------------------------------------------
    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
    #------------------------------------------------------------------------
    # * Enable Key
    #------------------------------------------------------------------------
    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

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end

Let me know if you need any help. If you don't have the SDK, just erase the SDK lines.
 

CERU

Member

Error line 162

Code:
    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 # ERROR HERE!
      end
      # Return Original Dir Test
      return dir
    end
  end
end
 
Silly me. Try this:

Code:
    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
 

CERU

Member

Okay I fixed that, and that error message went away, but a new error message came up.

line 80: NoMethodError occured. undefined method 'each' for nil:NilClass

@disabled_timer.each do |key, timer|

That sounds like its something that RPG Maker should inherently be able to read though ...

I also deleted the SDK lines and ...
 

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