Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> 


———
Before you ask! Read! ;)

You must have 30+ Posts to create a topic here!

Thanks for reading!
———

 
Reply to this topicStart new topic
> WASD Movement, Give me hand?
swick
post Sep 5 2009, 03:44 PM
Post #1


Level 1
Group Icon

Group: Member
Posts: 5
Type: Artist
RM Skill: Skilled




Hey there, not sure if I'm posting this in the right place, but if I'm not, I apoligize.

But I have a question, are there any scripts out there for RPG Maker VX that allow you to replace the arrow keys with the W, A, S, and D keys on your keyboard? If anyone can give me a hand it would be very appreciated!
Go to the top of the page
 
+Quote Post
   
guzzleboy478
post Sep 5 2009, 03:59 PM
Post #2


Level 7
Group Icon

Group: Revolutionary
Posts: 109
Type: None
RM Skill: Skilled




Here's a good script. It allows you to use your entire keyboard.

Look around lines 258 to 265.
CODE
when Input::DOWN
keys.push(Input:biggrin.gifN)
when Input::UP
keys.push(Input::UPs)
when Input::LEFT
keys.push(Input::LT)
when Input::RIGHT
keys.push(Input::RT)


To replace down for example, where it says keys.push(Input:biggrin.gifN) Change Input:biggrin.gifN to Input::Letters["S"]. Continue to do that for the others. Just remember that the smile faces are actually ":.D" without the quotations or the period(.)
Attached File(s)
Attached File  Keyboard_Input.txt ( 13.9K ) Number of downloads: 24
 
Go to the top of the page
 
+Quote Post
   
swick
post Sep 5 2009, 04:28 PM
Post #3


Level 1
Group Icon

Group: Member
Posts: 5
Type: Artist
RM Skill: Skilled




Okay I believe I've done it right...this is how it looks:
CODE
when Input::DOWN
keys.push(Input::Letters["S"])
when Input::UP
keys.push(Input::Letters["W"])
when Input::LEFT
keys.push(Input::Letters["A"])
when Input::RIGHT
keys.push(Input::Letters["D"])

And I start the game, everything works fine, but whenever I push the W, A, S, and D keys, it still doesn't work. Any ideas?
Go to the top of the page
 
+Quote Post
   
guzzleboy478
post Sep 5 2009, 09:16 PM
Post #4


Level 7
Group Icon

Group: Revolutionary
Posts: 109
Type: None
RM Skill: Skilled




Sorry about that. A momentary lapse in perfection. Try the one below. It worked for me in a blank project so it should work for you.
Attached File(s)
Attached File  Keyboard_Input.txt ( 13.97K ) Number of downloads: 47
 
Go to the top of the page
 
+Quote Post
   
swick
post Sep 6 2009, 10:19 PM
Post #5


Level 1
Group Icon

Group: Member
Posts: 5
Type: Artist
RM Skill: Skilled




QUOTE (guzzleboy478 @ Sep 5 2009, 10:16 PM) *
Sorry about that. A momentary lapse in perfection. Try the one below. It worked for me in a blank project so it should work for you.

Haha, oh yeah it works alright with in-game movement. Only now I can't move around in any menus using either the arrow keys OR the WASD keys. o.O
Go to the top of the page
 
+Quote Post
   
Michael
post Sep 6 2009, 11:01 PM
Post #6


Level 33
Group Icon

Group: Revolutionary
Posts: 838
Type: Writer
RM Skill: Skilled




This script looks nice, I'm going to try it. So you could move your character using any keyboard key as long as you set it to the right one, nice.
Go to the top of the page
 
+Quote Post
   
miget man12
post Sep 7 2009, 08:39 AM
Post #7


Making a Comeback
Group Icon

Group: Revolutionary
Posts: 393
Type: Musician
RM Skill: Intermediate




What you could do(and it's probably more effective) is simply put this in a new tab below the input script:
CODE
module Input
  DOWN = Letters["S"]
  UP = Letters["W"]
  LEFT = Letters["A"]
  RIGHT = Letters["D"]
end
Let me know if this doesn't work.

~Miget man12


__________________________
By the way:


I'm bored because it's summer so I decided to drop by for a bit.
Go to the top of the page
 
+Quote Post
   
guzzleboy478
post Sep 7 2009, 10:11 AM
Post #8


Level 7
Group Icon

Group: Revolutionary
Posts: 109
Type: None
RM Skill: Skilled




@swick
That's odd, I can move around in the menu fine with the arrow keys but not WASD.

@midgetman
I tried your snippet and it didn't seem to make a difference.
Go to the top of the page
 
+Quote Post
   
miget man12
post Sep 7 2009, 12:29 PM
Post #9


Making a Comeback
Group Icon

Group: Revolutionary
Posts: 393
Type: Musician
RM Skill: Intermediate




Oh, silly me! I don't know what I was thinking:D Anyway, this will fix the menu thing(it's because you didn't do it for Input.repeat, and Input.press, for that matter):
CODE
#===============================================================================
# VX Input Module
#===============================================================================
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 = 0x1B
  LT = 0x25
  UPs = 0x26
  RT = 0x27
  DN = 0x28
  Space = 32
  Numberkeys = {}
  Numberkeys[0] = 48
  Numberkeys[1] = 49
  Numberkeys[2] = 50
  Numberkeys[3] = 51
  Numberkeys[4] = 52
  Numberkeys[5] = 53
  Numberkeys[6] = 54
  Numberkeys[7] = 55
  Numberkeys[8] = 56
  Numberkeys[9] = 57
  Numberpad = {}
  Numberpad[0] = 45
  Numberpad[1] = 35
  Numberpad[2] = 40
  Numberpad[3] = 34
  Numberpad[4] = 37
  Numberpad[5] = 12
  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
  State = Win32API.new('user32','GetKeyState',['i'],'i')
  Key = Win32API.new('user32','GetAsyncKeyState',['i'],'i')
#-------------------------------------------------------------------------------
  
  USED_KEYS = [Mouse_Left, Mouse_Right, Mouse_Middle]
  
  module_function
  
  def Input.getstate(key)
    return true unless State.call(key).between?(0, 1)
    return false
  end
  
  def Input.testkey(key)
    Key.call(key) & 0x01 == 1
  end
  
  def Input.update
    @keys = []
    @keys.push(Input::Mouse_Left) if Input.testkey(Input::Mouse_Left)
    @keys.push(Input::Mouse_Right) if Input.testkey(Input::Mouse_Right)
    @keys.push(Input::Back) if Input.testkey(Input::Back)
    @keys.push(Input::Tab) if Input.testkey(Input::Tab)
    @keys.push(Input::Enter) if Input.testkey(Input::Enter)
    @keys.push(Input::Shift) if Input.testkey(Input::Shift)
    @keys.push(Input::Ctrl) if Input.testkey(Input::Ctrl)
    @keys.push(Input::Alt) if Input.testkey(Input::Alt)
    @keys.push(Input::Esc) if Input.testkey(Input::Esc)
    for key in Input::Letters.values
      @keys.push(key) if Input.testkey(key)
    end
    for key in Input::Numberkeys.values
      @keys.push(key) if Input.testkey(key)
    end
    for key in Input::Numberpad.values
      @keys.push(key) if Input.testkey(key)
    end
    for key in Input::Fkeys.values
      @keys.push(key) if Input.testkey(key)
    end
    @keys.push(Input::Collon) if Input.testkey(Input::Collon)
    @keys.push(Input::Equal) if Input.testkey(Input::Equal)
    @keys.push(Input::Comma) if Input.testkey(Input::Comma)
    @keys.push(Input::Underscore) if Input.testkey(Input::Underscore)
    @keys.push(Input::Dot) if Input.testkey(Input::Dot)
    @keys.push(Input::Backslash) if Input.testkey(Input::Backslash)
    @keys.push(Input::Lb) if Input.testkey(Input::Lb)
    @keys.push(Input::Rb) if Input.testkey(Input::Rb)
    @keys.push(Input::Quote) if Input.testkey(Input::Quote)
    @keys.push(Input::Space) if Input.testkey(Input::Space)
    @keys.push(Input::LT) if Input.testkey(Input::LT)
    @keys.push(Input::UPs) if Input.testkey(Input::UPs)
    @keys.push(Input::RT) if Input.testkey(Input::RT)
    @keys.push(Input::DN) if Input.testkey(Input::DN)
    @pressed = []
    @pressed.push(Input::Space) if Input.getstate(Input::Space)
    @pressed.push(Input::Mouse_Left) if Input.getstate(Input::Mouse_Left)
    @pressed.push(Input::Mouse_Right) if Input.getstate(Input::Mouse_Right)
    @pressed.push(Input::Back) if Input.getstate(Input::Back)
    @pressed.push(Input::Tab) if Input.getstate(Input::Tab)
    @pressed.push(Input::Enter) if Input.getstate(Input::Enter)
    @pressed.push(Input::Shift) if Input.getstate(Input::Shift)
    @pressed.push(Input::Ctrl) if Input.getstate(Input::Ctrl)
    @pressed.push(Input::Alt) if Input.getstate(Input::Alt)
    @pressed.push(Input::Esc) if Input.getstate(Input::Esc)
    @pressed.push(Input::LT) if Input.getstate(Input::LT)
    @pressed.push(Input::UPs) if Input.getstate(Input::UPs)
    @pressed.push(Input::RT) if Input.getstate(Input::RT)
    @pressed.push(Input::DN) if Input.getstate(Input::DN)
    for key in Input::Numberkeys.values
      @pressed.push(key) if Input.getstate(key)
    end
    for key in Input::Numberpad.values
      @pressed.push(key) if Input.getstate(key)
    end
    for key in Input::Letters.values
      @pressed.push(key) if Input.getstate(key)
    end
    for key in Input::Fkeys.values
      @pressed.push(key) if Input.getstate(key)
    end
    @pressed.push(Input::Collon) if Input.getstate(Input::Collon)
    @pressed.push(Input::Equal) if Input.getstate(Input::Equal)
    @pressed.push(Input::Comma) if Input.getstate(Input::Comma)
    @pressed.push(Input::Underscore) if Input.getstate(Input::Underscore)
    @pressed.push(Input::Dot) if Input.getstate(Input::Dot)
    @pressed.push(Input::Backslash) if Input.getstate(Input::Backslash)
    @pressed.push(Input::Lb) if Input.getstate(Input::Lb)
    @pressed.push(Input::Rb) if Input.getstate(Input::Rb)
    @pressed.push(Input::Quote) if Input.getstate(Input::Quote)  
  end

  def Input.triggerd?(key)
    return true if @keys.include?(key)
    return false
  end

  def Input.pressed?(key)
    return true if @pressed.include?(key)
    return false
  end

  def Input.dir4
    return 2 if Input.pressed?(Input::Letters["S"])
    return 4 if Input.pressed?(Input::Letters["A"])
    return 6 if Input.pressed?(Input::Letters["D"])
    return 8 if Input.pressed?(Input::Letters["W"])
    return 0
  end

  def trigger?(key)
    keys = []
    case key
    when Input::DOWN
      keys.push(Input::Letters["S"])
    when Input::UP
      keys.push(Input::Letters["W"])
    when Input::LEFT
      keys.push(Input::Letters["A"])
    when Input::RIGHT
      keys.push(Input::Letters["D"])
    when Input::A
      keys.push(Input::Shift)
    when Input::B
      keys.push(Input::Esc, Input::Numberpad[0], Input::Letters["X"])
    when Input::C
      keys.push(Input::Space, Input::Enter)
    when Input::L
      keys.push(Input::Letters["Q"])
    when Input::R
      keys.push(Input::Letters["W"])
    when Input::X
      keys.push(Input::Letters["A"])
    when Input::Y
      keys.push(Input::Letters["S"])
    when Input::Z
      keys.push(Input::Letters["D"])
    when Input::F5
      keys.push(Input::Fkeys[5])
    when Input::F6
      keys.push(Input::Fkeys[6])
    when Input::F7
      keys.push(Input::Fkeys[7])
    when Input::F8
      keys.push(Input::Fkeys[8])
    when Input::F9
      keys.push(Input::Fkeys[9])
    when Input::CTRL
      keys.push(Input::Ctrl)
    when Input::ALT
      keys.push(Input::Alt)
    else
      keys.push(key)
    end
    for k in keys
     if Input.triggerd?(k)
       return true
     end
   end
   return false
end

def repeat?(key)
   keys = []
   case key
   when Input::DOWN
     keys.push(Input::Letters["S"])
   when Input::UP
     keys.push(Input::Letters["W"])
   when Input::LEFT
     keys.push(Input::Letters["A"])
   when Input::RIGHT
     keys.push(Input::Letters["D"])
   when Input::A
     keys.push(Input::Shift)
   when Input::B
     keys.push(Input::Esc, Input::Numberpad[0], Input::Letters["X"])
   when Input::C
     keys.push(Input::Space, Input::Enter)
   when Input::L
     keys.push(Input::Letters["Q"])
   when Input::R
     keys.push(Input::Letters["W"])
   when Input::X
     keys.push(Input::Letters["A"])
   when Input::Y
     keys.push(Input::Letters["S"])
   when Input::Z
     keys.push(Input::Letters["D"])
   when Input::F5
     keys.push(Input::Fkeys[5])
   when Input::F6
     keys.push(Input::Fkeys[6])
   when Input::F7
     keys.push(Input::Fkeys[7])
   when Input::F8
     keys.push(Input::Fkeys[8])
   when Input::F9
     keys.push(Input::Fkeys[9])
   when Input::CTRL
     keys.push(Input::Ctrl)
   when Input::ALT
     keys.push(Input::Alt)
   else
     keys.push(key)
   end
   for k in keys
     if Input.triggerd?(k)
       return true
     end
   end
   return false
  end    

  def press?(key)
    keys = []
    case key
    when Input::DOWN
      keys.push(Input::Letters["S"])
    when Input::UP
      keys.push(Input::Letters["W"])
    when Input::LEFT
      keys.push(Input::Letters["A"])
    when Input::RIGHT
      keys.push(Input::Letters["D"])
    when Input::A
      keys.push(Input::Shift)
    when Input::B
      keys.push(Input::Esc, Input::Numberpad[0], Input::Letters["X"])
    when Input::C
      keys.push(Input::Space, Input::Enter)
    when Input::L
      keys.push(Input::Letters["Q"])
    when Input::R
      keys.push(Input::Letters["W"])
    when Input::X
      keys.push(Input::Letters["A"])
    when Input::Y
      keys.push(Input::Letters["S"])
    when Input::Z
      keys.push(Input::Letters["D"])  
    when Input::F5
      keys.push(Input::Fkeys[5])
    when Input::F6
      keys.push(Input::Fkeys[6])
    when Input::F7
      keys.push(Input::Fkeys[7])
    when Input::F8
      keys.push(Input::Fkeys[8])
    when Input::F9
      keys.push(Input::Fkeys[9])
    when Input::CTRL
      keys.push(Input::Ctrl)
    when Input::ALT
      keys.push(Input::Alt)
    else
      keys.push(key)
    end
    for k in keys
     if Input.pressed?(k)
       return true
     end
   end
   return false
  end    

  def check(key)
    Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1  # key 0
  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 Input.C
    Input.trigger?(C)
  end

  def Input.B
    Input.trigger?(B)
  end

  def Input.A
    Input.trigger?(A)
  end

  def Input.Down
    Input.trigger?(DOWN)
  end

  def Input.Up
    Input.trigger?(UP)
  end

  def Input.Right
    Input.trigger?(RIGHT)
  end

  def Input.Left
    Input.trigger?(LEFT)
  end

  def Input.Anykey
    if A or B or C or Down or Up or Right or Left
      return true
    else
      return false
    end
  end
  
  def Input.name?(num)
    return "MOUSE PRIMARY" if num==1
    return "MOUSE SECONDARY" if num==2
    return "MOUSE MIDDLE" if num==4
    return "MOUSE 4TH" if num==5
    return "MOUSE 5TH" if num==6
    return "BACKSPACE" if num==8
    return "TAB" if num==9
    return "RETURN" if num==13
    return "SHIFT" if num==16
    return "CTLR" if num==17
    return "ALT" if num==18
    return "CAPS LOCK" if num==20
    return "ESCAPE" if num==27
    return "SPACE" if num==32
    return "PGUP" if num==33
    return "PGDN" if num==34
    return "END" if num==35
    return "HOME" if num==36
    return "LEFT" if num==37
    return "UP" if num==38
    return "RIGHT" if num==39
    return "DOWN" if num==40
    return "SNAPSHOT" if num==44
    return "INSERT" if num==45
    return "DELETE" if num==46
    return "0" if num==48
    return "1" if num==49
    return "2" if num==50
    return "3" if num==51
    return "4" if num==52
    return "5" if num==53
    return "6" if num==54
    return "7" if num==55
    return "8" if num==56
    return "9" if num==57
    return "A" if num==65
    return "B" if num==66
    return "C" if num==67
    return "D" if num==68
    return "E" if num==69
    return "F" if num==70
    return "G" if num==71
    return "H" if num==72
    return "I" if num==73
    return "J" if num==74
    return "K" if num==75
    return "L" if num==76
    return "M" if num==77
    return "N" if num==78
    return "O" if num==79
    return "P" if num==80
    return "Q" if num==81
    return "R" if num==82
    return "S" if num==83
    return "T" if num==84
    return "U" if num==85
    return "V" if num==86
    return "W" if num==87
    return "X" if num==88
    return "Y" if num==89
    return "Z" if num==90
    return "LWIN" if num==91
    return "RWIN" if num==92
    return "APPS" if num==93
    return "0" if num==96
    return "1" if num==97
    return "2" if num==98
    return "3" if num==99
    return "4" if num==100
    return "5" if num==101
    return "6" if num==102
    return "7" if num==103
    return "8" if num==104
    return "9" if num==105
    return "*" if num==106
    return "+" if num==107
    return "-" if num==109
    return "." if num==110
    return "/" if num==111
    return "F1" if num==112
    return "F2" if num==113
    return "F3" if num==114
    return "F4" if num==115
    return "F5" if num==116
    return "F6" if num==117
    return "F7" if num==118
    return "F8" if num==119
    return "F9" if num==120
    return "F10" if num==121
    return "F11" if num==122
    return "F12" if num==123
    return "NUM LOCK" if num==144
    return "SCROLL LOCK" if num==145
    return "LEFT SHIFT" if num==160
    return "RIGHT SHIFT" if num==161
    return "LEFT CTRL" if num==162
    return "RIGHT CTRL" if num==163
    return "LEFT ALT" if num==164
    return "RIGHT ALT" if num==165
    return ";" if num==186
    return "=" if num==187
    return "," if num==188
    return "_" if num==189
    return "." if num==190
    return "/" if num==191
    return "`" if num==192
    return "[" if num==219
    return " \\ " if num==220
    return "]" if num==221
    return "'" if num==222
    return "??? - " + "#{num}"
  end  
end


~Miget man12


__________________________
By the way:


I'm bored because it's summer so I decided to drop by for a bit.
Go to the top of the page
 
+Quote Post
   
guzzleboy478
post Sep 7 2009, 02:02 PM
Post #10


Level 7
Group Icon

Group: Revolutionary
Posts: 109
Type: None
RM Skill: Skilled




Ah... I hadn't thought of that. Still just learning how to script anyway. sweat.gif By the way, it works beautifully.
Go to the top of the page
 
+Quote Post
   
miget man12
post Sep 7 2009, 03:06 PM
Post #11


Making a Comeback
Group Icon

Group: Revolutionary
Posts: 393
Type: Musician
RM Skill: Intermediate




Yeah, that's something to keep in mind when working with the Input module - all windows use Input.repeat?, not Input.trigger?. Also, you should modify Input.repeat? and .press? if you're chaning Input.trigger? :D

~MIget man12


__________________________
By the way:


I'm bored because it's summer so I decided to drop by for a bit.
Go to the top of the page
 
+Quote Post
   
guzzleboy478
post Sep 7 2009, 03:25 PM
Post #12


Level 7
Group Icon

Group: Revolutionary
Posts: 109
Type: None
RM Skill: Skilled




Alright, thanks for the tip.
Go to the top of the page
 
+Quote Post
   
Kuma-san
post Sep 7 2009, 03:50 PM
Post #13


「VOIDVOIDVOID」
Group Icon

Group: Revolutionary
Posts: 291
Type: Writer
RM Skill: Skilled




I moved this to RGSS2 Script Requests.


__________________________
[Show/Hide] Signature.
[Show/Hide] Best real-life quote. Ever
Teacher- Do you think your cute? Do you think your funny?
Student- I think I'm SEXY.

[Show/Hide] Userbars






[Show/Hide] My Tarot Card.

"Prudence, Caution, Deliberation.

The Hermit points to all things hidden, such as knowledge and inspiration,hidden enemies. The illumination is from within, and retirement from participation in current events.

The Hermit is a card of introspection, analysis and, well, virginity. You do not desire to socialize; the card indicates, instead, a desire for peace and solitude. You prefer to take the time to think, organize, ruminate, take stock. There may be feelings of frustration and discontent but these feelings eventually lead to enlightenment, illumination, clarity.

The Hermit represents a wise, inspirational person, friend, teacher, therapist. This a person who can shine a light on things that were previously mysterious and confusing.
"
Go to the top of the page
 
+Quote Post
   
Xothos
post Dec 22 2009, 09:43 PM
Post #14



Group Icon

Group: Member
Posts: 1
Type: Developer
RM Skill: Beginner




Alright, so this is my first game im making and spent some time and found this post. Love the script, but made some changes :-). Posting them just incase someone else has the same needs i do.

Pretty Simple: The following code is the above script just with some added lines that activate the arrow keys as well. So whoever the player is can use either the WASD or Arrow key movement. Either separate or together. Nothing special, but give me a break i've never seen ruby till just now :-D. But here it is, if it pisses off the origional writer that i messed with it, i'll remove.

Instructions: Remove the pound (#) signs in front of all the code following the "Dual Key Movement" comment blocks and your in business.

CODE
#===============================================================================
# VX Input Module
#===============================================================================
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 = 0x1B
LT = 0x25
UPs = 0x26
RT = 0x27
DN = 0x28
Space = 32
Numberkeys = {}
Numberkeys[0] = 48
Numberkeys[1] = 49
Numberkeys[2] = 50
Numberkeys[3] = 51
Numberkeys[4] = 52
Numberkeys[5] = 53
Numberkeys[6] = 54
Numberkeys[7] = 55
Numberkeys[8] = 56
Numberkeys[9] = 57
Numberpad = {}
Numberpad[0] = 45
Numberpad[1] = 35
Numberpad[2] = 40
Numberpad[3] = 34
Numberpad[4] = 37
Numberpad[5] = 12
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
State = Win32API.new('user32','GetKeyState',['i'],'i')
Key = Win32API.new('user32','GetAsyncKeyState',['i'],'i')
#-------------------------------------------------------------------------------

USED_KEYS = [Mouse_Left, Mouse_Right, Mouse_Middle]

module_function

def Input.getstate(key)
return true unless State.call(key).between?(0, 1)
return false
end

def Input.testkey(key)
Key.call(key) & 0x01 == 1
end

def Input.update
@keys = []
@keys.push(Input::Mouse_Left) if Input.testkey(Input::Mouse_Left)
@keys.push(Input::Mouse_Right) if Input.testkey(Input::Mouse_Right)
@keys.push(Input::Back) if Input.testkey(Input::Back)
@keys.push(Input::Tab) if Input.testkey(Input::Tab)
@keys.push(Input::Enter) if Input.testkey(Input::Enter)
@keys.push(Input::Shift) if Input.testkey(Input::Shift)
@keys.push(Input::Ctrl) if Input.testkey(Input::Ctrl)
@keys.push(Input::Alt) if Input.testkey(Input::Alt)
@keys.push(Input::Esc) if Input.testkey(Input::Esc)
for key in Input::Letters.values
@keys.push(key) if Input.testkey(key)
end
for key in Input::Numberkeys.values
@keys.push(key) if Input.testkey(key)
end
for key in Input::Numberpad.values
@keys.push(key) if Input.testkey(key)
end
for key in Input::Fkeys.values
@keys.push(key) if Input.testkey(key)
end
@keys.push(Input::Collon) if Input.testkey(Input::Collon)
@keys.push(Input::Equal) if Input.testkey(Input::Equal)
@keys.push(Input::Comma) if Input.testkey(Input::Comma)
@keys.push(Input::Underscore) if Input.testkey(Input::Underscore)
@keys.push(Input::Dot) if Input.testkey(Input::Dot)
@keys.push(Input::Backslash) if Input.testkey(Input::Backslash)
@keys.push(Input::Lb) if Input.testkey(Input::Lb)
@keys.push(Input::Rb) if Input.testkey(Input::Rb)
@keys.push(Input::Quote) if Input.testkey(Input::Quote)
@keys.push(Input::Space) if Input.testkey(Input::Space)
@keys.push(Input::LT) if Input.testkey(Input::LT)
@keys.push(Input::UPs) if Input.testkey(Input::UPs)
@keys.push(Input::RT) if Input.testkey(Input::RT)
@keys.push(Input::DN) if Input.testkey(Input::DN)
@pressed = []
@pressed.push(Input::Space) if Input.getstate(Input::Space)
@pressed.push(Input::Mouse_Left) if Input.getstate(Input::Mouse_Left)
@pressed.push(Input::Mouse_Right) if Input.getstate(Input::Mouse_Right)
@pressed.push(Input::Back) if Input.getstate(Input::Back)
@pressed.push(Input::Tab) if Input.getstate(Input::Tab)
@pressed.push(Input::Enter) if Input.getstate(Input::Enter)
@pressed.push(Input::Shift) if Input.getstate(Input::Shift)
@pressed.push(Input::Ctrl) if Input.getstate(Input::Ctrl)
@pressed.push(Input::Alt) if Input.getstate(Input::Alt)
@pressed.push(Input::Esc) if Input.getstate(Input::Esc)
@pressed.push(Input::LT) if Input.getstate(Input::LT)
@pressed.push(Input::UPs) if Input.getstate(Input::UPs)
@pressed.push(Input::RT) if Input.getstate(Input::RT)
@pressed.push(Input::DN) if Input.getstate(Input::DN)
for key in Input::Numberkeys.values
@pressed.push(key) if Input.getstate(key)
end
for key in Input::Numberpad.values
@pressed.push(key) if Input.getstate(key)
end
for key in Input::Letters.values
@pressed.push(key) if Input.getstate(key)
end
for key in Input::Fkeys.values
@pressed.push(key) if Input.getstate(key)
end
@pressed.push(Input::Collon) if Input.getstate(Input::Collon)
@pressed.push(Input::Equal) if Input.getstate(Input::Equal)
@pressed.push(Input::Comma) if Input.getstate(Input::Comma)
@pressed.push(Input::Underscore) if Input.getstate(Input::Underscore)
@pressed.push(Input::Dot) if Input.getstate(Input::Dot)
@pressed.push(Input::Backslash) if Input.getstate(Input::Backslash)
@pressed.push(Input::Lb) if Input.getstate(Input::Lb)
@pressed.push(Input::Rb) if Input.getstate(Input::Rb)
@pressed.push(Input::Quote) if Input.getstate(Input::Quote)
end

def Input.triggerd?(key)
return true if @keys.include?(key)
return false
end

def Input.pressed?(key)
return true if @pressed.include?(key)
return false
end

def Input.dir4
return 2 if Input.pressed?(Input::Letters["S"])
return 4 if Input.pressed?(Input::Letters["A"])
return 6 if Input.pressed?(Input::Letters["D"])
return 8 if Input.pressed?(Input::Letters["W"])

#=================
#Dual Key Movement
#=================
#return 2 if Input.pressed?(Input::DN)
#return 4 if Input.pressed?(Input::LT)
#return 6 if Input.pressed?(Input::RT)
#return 8 if Input.pressed?(Input::UPs)

return 0
end

def trigger?(key)
keys = []
case key
when Input::DOWN
keys.push(Input::Letters["S"])
when Input::UP
keys.push(Input::Letters["W"])
when Input::LEFT
keys.push(Input::Letters["A"])
when Input::RIGHT
keys.push(Input::Letters["D"])
when Input::A
keys.push(Input::Shift)
when Input::B
keys.push(Input::Esc, Input::Numberpad[0], Input::Letters["X"])
when Input::C
keys.push(Input::Space, Input::Enter)
when Input::L
keys.push(Input::Letters["Q"])
when Input::R
keys.push(Input::Letters["W"])
when Input::X
keys.push(Input::Letters["A"])
when Input::Y
keys.push(Input::Letters["S"])
when Input::Z
keys.push(Input::Letters["D"])
when Input::F5
keys.push(Input::Fkeys[5])
when Input::F6
keys.push(Input::Fkeys[6])
when Input::F7
keys.push(Input::Fkeys[7])
when Input::F8
keys.push(Input::Fkeys[8])
when Input::F9
keys.push(Input::Fkeys[9])
when Input::CTRL
keys.push(Input::Ctrl)
when Input::ALT
keys.push(Input::Alt)

#=================
#Dual Key Movement
#=================
#when Input::DOWN
#keys.push(Input::DN)
#when Input::UP
#keys.push(Input::UPs)
#when Input::LEFT
#keys.push(Input::LT)
#when Input::RIGHT
#keys.push(Input::RT)
#when Input::R
#keys.push(Input::UPs)
#when Input::X
#keys.push(Input::LT)
#when Input::Y
#keys.push(Input::DN)
#when Input::Z
#keys.push(Input::RT)

else
keys.push(key)
end
for k in keys
if Input.triggerd?(k)
return true
end
end
return false
end

def repeat?(key)
keys = []
case key
when Input::DOWN
keys.push(Input::Letters["S"])
when Input::UP
keys.push(Input::Letters["W"])
when Input::LEFT
keys.push(Input::Letters["A"])
when Input::RIGHT
keys.push(Input::Letters["D"])
when Input::A
keys.push(Input::Shift)
when Input::B
keys.push(Input::Esc, Input::Numberpad[0], Input::Letters["X"])
when Input::C
keys.push(Input::Space, Input::Enter)
when Input::L
keys.push(Input::Letters["Q"])
when Input::R
keys.push(Input::Letters["W"])
when Input::X
keys.push(Input::Letters["A"])
when Input::Y
keys.push(Input::Letters["S"])
when Input::Z
keys.push(Input::Letters["D"])
when Input::F5
keys.push(Input::Fkeys[5])
when Input::F6
keys.push(Input::Fkeys[6])
when Input::F7
keys.push(Input::Fkeys[7])
when Input::F8
keys.push(Input::Fkeys[8])
when Input::F9
keys.push(Input::Fkeys[9])
when Input::CTRL
keys.push(Input::Ctrl)
when Input::ALT
keys.push(Input::Alt)

#=================
#Dual Key Movement
#=================
#when Input::DOWN
#keys.push(Input::DN)
#when Input::UP
#keys.push(Input::UPs)
#when Input::LEFT
#keys.push(Input::LT)
#when Input::RIGHT
#keys.push(Input::RT)
#when Input::R
#keys.push(Input::UPs)
#when Input::X
#keys.push(Input::LT)
#when Input::Y
#keys.push(Input::DN)
#when Input::Z
#keys.push(Input::RT)

else
keys.push(key)
end
for k in keys
if Input.triggerd?(k)
return true
end
end
return false
end

def press?(key)
keys = []
case key
when Input::DOWN
keys.push(Input::Letters["S"])
when Input::UP
keys.push(Input::Letters["W"])
when Input::LEFT
keys.push(Input::Letters["A"])
when Input::RIGHT
keys.push(Input::Letters["D"])
when Input::A
keys.push(Input::Shift)
when Input::B
keys.push(Input::Esc, Input::Numberpad[0], Input::Letters["X"])
when Input::C
keys.push(Input::Space, Input::Enter)
when Input::L
keys.push(Input::Letters["Q"])
when Input::R
keys.push(Input::Letters["W"])
when Input::X
keys.push(Input::Letters["A"])
when Input::Y
keys.push(Input::Letters["S"])
when Input::Z
keys.push(Input::Letters["D"])
when Input::F5
keys.push(Input::Fkeys[5])
when Input::F6
keys.push(Input::Fkeys[6])
when Input::F7
keys.push(Input::Fkeys[7])
when Input::F8
keys.push(Input::Fkeys[8])
when Input::F9
keys.push(Input::Fkeys[9])
when Input::CTRL
keys.push(Input::Ctrl)
when Input::ALT
keys.push(Input::Alt)

#=================
#Dual Key Movement
#=================
#when Input::DOWN
#keys.push(Input::DN)
#when Input::UP
#keys.push(Input::UPs)
#when Input::LEFT
#keys.push(Input::LT)
#when Input::RIGHT
#keys.push(Input::RT)
#when Input::R
#keys.push(Input::UPs)
#when Input::X
#keys.push(Input::LT)
#when Input::Y
#keys.push(Input::DN)
#when Input::Z
#keys.push(Input::RT)

else
keys.push(key)
end
for k in keys
if Input.pressed?(k)
return true
end
end
return false
end

def check(key)
Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1 # key 0
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 Input.C
Input.trigger?(C)
end

def Input.B
Input.trigger?(B)
end

def Input.A
Input.trigger?(A)
end

def Input.Down
Input.trigger?(DOWN)
end

def Input.Up
Input.trigger?(UP)
end

def Input.Right
Input.trigger?(RIGHT)
end

def Input.Left
Input.trigger?(LEFT)
end

def Input.Anykey
if A or B or C or Down or Up or Right or Left
return true
else
return false
end
end

def Input.name?(num)
return "MOUSE PRIMARY" if num==1
return "MOUSE SECONDARY" if num==2
return "MOUSE MIDDLE" if num==4
return "MOUSE 4TH" if num==5
return "MOUSE 5TH" if num==6
return "BACKSPACE" if num==8
return "TAB" if num==9
return "RETURN" if num==13
return "SHIFT" if num==16
return "CTLR" if num==17
return "ALT" if num==18
return "CAPS LOCK" if num==20
return "ESCAPE" if num==27
return "SPACE" if num==32
return "PGUP" if num==33
return "PGDN" if num==34
return "END" if num==35
return "HOME" if num==36
return "LEFT" if num==37
return "UP" if num==38
return "RIGHT" if num==39
return "DOWN" if num==40
return "SNAPSHOT" if num==44
return "INSERT" if num==45
return "DELETE" if num==46
return "0" if num==48
return "1" if num==49
return "2" if num==50
return "3" if num==51
return "4" if num==52
return "5" if num==53
return "6" if num==54
return "7" if num==55
return "8" if num==56
return "9" if num==57
return "A" if num==65
return "B" if num==66
return "C" if num==67
return "D" if num==68
return "E" if num==69
return "F" if num==70
return "G" if num==71
return "H" if num==72
return "I" if num==73
return "J" if num==74
return "K" if num==75
return "L" if num==76
return "M" if num==77
return "N" if num==78
return "O" if num==79
return "P" if num==80
return "Q" if num==81
return "R" if num==82
return "S" if num==83
return "T" if num==84
return "U" if num==85
return "V" if num==86
return "W" if num==87
return "X" if num==88
return "Y" if num==89
return "Z" if num==90
return "LWIN" if num==91
return "RWIN" if num==92
return "APPS" if num==93
return "0" if num==96
return "1" if num==97
return "2" if num==98
return "3" if num==99
return "4" if num==100
return "5" if num==101
return "6" if num==102
return "7" if num==103
return "8" if num==104
return "9" if num==105
return "*" if num==106
return "+" if num==107
return "-" if num==109
return "." if num==110
return "/" if num==111
return "F1" if num==112
return "F2" if num==113
return "F3" if num==114
return "F4" if num==115
return "F5" if num==116
return "F6" if num==117
return "F7" if num==118
return "F8" if num==119
return "F9" if num==120
return "F10" if num==121
return "F11" if num==122
return "F12" if num==123
return "NUM LOCK" if num==144
return "SCROLL LOCK" if num==145
return "LEFT SHIFT" if num==160
return "RIGHT SHIFT" if num==161
return "LEFT CTRL" if num==162
return "RIGHT CTRL" if num==163
return "LEFT ALT" if num==164
return "RIGHT ALT" if num==165
return ";" if num==186
return "=" if num==187
return "," if num==188
return "_" if num==189
return "." if num==190
return "/" if num==191
return "`" if num==192
return "[" if num==219
return " \\ " if num==220
return "]" if num==221
return "'" if num==222
return "??? - " + "#{num}"
end
end


This post has been edited by Xothos: Dec 27 2009, 12:42 PM
Go to the top of the page
 
+Quote Post
   
Delous
post Feb 20 2012, 07:35 PM
Post #15



Group Icon

Group: Member
Posts: 2
Type: None
RM Skill: Undisclosed




I stumbled across this trying to find a way to change the movment controls for a friend of mine. his down arrow doesnt work so im trying to set it to WASD. Ive tried these scripts but when i get into the game it doesnt seem to change anything.

Im using rpg maker VX and im placing the scripts in the keyboard input.txt file in the game folder.
Go to the top of the page
 
+Quote Post
   
Pacman
post Feb 21 2012, 03:32 AM
Post #16


Level 3
Group Icon

Group: Member
Posts: 34
Type: Scripter
RM Skill: Advanced




1. Massive necropost :/
2. You should be pasting the scripts above Main and below Materials in the Script Editor (F11).


__________________________
Go to the top of the page
 
+Quote Post
   
Delous
post Feb 21 2012, 06:16 AM
Post #17



Group Icon

Group: Member
Posts: 2
Type: None
RM Skill: Undisclosed




Lol i didnt know where the post was in the forums i found it through searching google.
Thank you for your help though that fixed my problem perfectly.
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 08:32 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker