RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Adding a secod Enter key (action button)

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 88
Hey,

I wasn't able to find anything about this already on here, so I thought I'd ask;

Does anyone know how I might go about making a second action-key, and have events respond differently based on which key you hit?

For instance, say I want to have you swing a sword when you hit "Shift", but I want you to talk when you hit "enter" -- and, naturally, a given event would either yell at you for whacking it, or converse with you happily, based on which you did.

Any help would be greatly appreciated!

     ~ Nicholai

**
Rep:
Level 87
I'm not really sure because I've never done it but I could give you something that would give you the same result. Place an event for all of your people so that when you walk up to them and press the action key, it gives you a choice to talk or attack(or whatever other commands) and of course, make that ation happen. Now, I imagine this is probably a zelda style game so with all of your monsters, just make it so that when you press the action key next to them, it shows your animation and hurts them (If you don't know how to do this just say something and I'll show show you). and when they touch you, it will hurt you.

Also, a cool suggestion; you could make it to where when you choose to attack sertain people, it's like picking a fight. So, as soon as you hit them they start to attack you.

I'll check here later to see if you have any questions or comments.
I don't have a signature

**
Rep:
Level 88
I'm scared of my grandma. Wouldn't you be?
You could use a parallel process common event. Use the if key pressed, initiate action. Set a switch at the same time to makesure if a collision with an enemy will hurt them and turn it off after a wait command. If you need more keys to use here's a keyboard input module.
Code: [Select]
#==============================================================================
# Keyboard Input Module
#----------------------------------------------------------------------------
# Script by Cybersam
#==============================================================================

module Input
  @keys = []
  @pressed = []
  Mouse_Left = 1
  Mouse_Right = 2
  Mouse_Middle = 4
  Back= 8
  Tab = 9
  Enter = 13
  Shift = 16
  Ctrl = 17
  Alt = 18
  Esc = 27
  Space = 32
  Numberkeys = {}
  Numberkeys[0] = 48        # => 0
  Numberkeys[1] = 49        # => 1
  Numberkeys[2] = 50        # => 2
  Numberkeys[3] = 51        # => 3
  Numberkeys[4] = 52        # => 4
  Numberkeys[5] = 53        # => 5
  Numberkeys[6] = 54        # => 6
  Numberkeys[7] = 55        # => 7
  Numberkeys[8] = 56        # => 8
  Numberkeys[9] = 57        # => 9
  Numberpad = {}
  Numberpad[0] = 45
  Numberpad[1] = 35
  Numberpad[2] = 40
  Numberpad[3] = 34
  Numberpad[4] = 37
  Numberpad[5] = 31
  Numberpad[6] = 39
  Numberpad[7] = 36
  Numberpad[8] = 38
  Numberpad[9] = 33
  Letters = {}
  Letters["A"] = 65
  Letters["B"] = 66
  Letters["C"] = 67
  Letters["D"] = 68
  Letters["E"] = 69
  Letters["F"] = 70
  Letters["G"] = 71
  Letters["H"] = 72
  Letters["I"] = 73
  Letters["J"] = 74
  Letters["K"] = 75
  Letters["L"] = 76
  Letters["M"] = 77
  Letters["N"] = 78
  Letters["O"] = 79
  Letters["P"] = 80
  Letters["Q"] = 81
  Letters["R"] = 82
  Letters["S"] = 83
  Letters["T"] = 84
  Letters["U"] = 85
  Letters["V"] = 86
  Letters["W"] = 87
  Letters["X"] = 88
  Letters["Y"] = 89
  Letters["Z"] = 90
  Fkeys = {}
  Fkeys[1] = 112
  Fkeys[2] = 113
  Fkeys[3] = 114
  Fkeys[4] = 115
  Fkeys[5] = 116
  Fkeys[6] = 117
  Fkeys[7] = 118
  Fkeys[8] = 119
  Fkeys[9] = 120
  Fkeys[10] = 121
  Fkeys[11] = 122
  Fkeys[12] = 123
  Collon = 186            #  ; :
  Equal = 187             #  = +
  Comma = 188          #  , <
  Underscore = 189     #  - _
  Dot = 190                #  . >
  Backslash = 191       #  / ?
  Lb = 219                 #  [ {
  Rb = 221                 #  ] }
  Quote = 222            #  ' "
  #-------------------------------------------------------------------------------
  USED_KEYS = [Mouse_Left, Mouse_Right, Mouse_Middle]
  #-------------------------------------------------------------------------------
 
module_function
  #--------------------------------------------------------------------------
  def triggered?(key)
    Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1
  end
  #--------------------------------------------------------------------------
  def check(key)
    Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1
  end
  #--------------------------------------------------------------------------
  def pressed?(key)
    return true unless Win32API.new("user32","GetKeyState",['i'],'i').call(key).between?(0, 1)
    return false
  end
  #--------------------------------------------------------------------------
  def mouse_update
    @used_i = []
    for i in USED_KEYS
      x = check(i)
      if x == true
        @used_i.push(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  def self.C
    self.trigger?(C)
  end
  #--------------------------------------------------------------------------
  def self.B
    self.trigger?(B)
  end
  #--------------------------------------------------------------------------
  def self.A
    self.trigger?(A)
  end
  #--------------------------------------------------------------------------
  def self.Down
    self.trigger?(DOWN)
  end
  #--------------------------------------------------------------------------
  def self.Up
    self.trigger?(UP)
  end
  #--------------------------------------------------------------------------
  def self.Right
    self.trigger?(RIGHT)
  end
  #--------------------------------------------------------------------------
  def self.Left
    self.trigger?(LEFT)
  end
  #--------------------------------------------------------------------------
  def self.Anykey
    if A or B or C or Down or Up or Right or Left
      return true
    else
      return false
    end
  end
  #--------------------------------------------------------------------------
end
in a conditional branch statement use Input.pressed?(Key #) The corresponding key number goes with the comments in the script. Just put the script above all the other scripts in the database. Hope this helps.