Help - Search - Members - Calendar
Full Version: Some small scripting problem [Solved]
RPG RPG Revolution Forums > Scripting > Script Development and Support
Vexus
I'm editing Game_Player movement and with the help on google search I managed to make the character move using wasd instead of the arrow keys.

Now I was wondering if I could take it into a "higher level" but trying to make it if you press arrow key up OR w character moves up.

So anyone could help me with a little problem?

These are the lines of the script:

The default with arrow keys movement.
CODE
      
case Input.dir4
      when 2
        move_down
      when 4
        move_left
      when 6
        move_right
      when 8
        move_up
      #end


And this is the wasd part.
CODE
      if Input.press?(Input::Y)
         move_down
      elsif Input.press?(Input::X)
         move_left
      elsif Input.press?(Input::Z)
         move_right
      elsif Input.press?(Input::R)
         move_up
      end
    end


Thanks.
The Law G14
Hey smile.gif

You could just add them together using the "or" keyword, like this:

CODE
if Input.press?(Input::Y) or Input.press?(Input::DOWN)
         move_down
      elsif Input.press?(Input::X) or Input.press?(Input::LEFT)
         move_left
      elsif Input.press?(Input::Z) or Input.press?(Input::RIGHT)
         move_right
      elsif Input.press?(Input::R) or Input.press?(Input::UP)
         move_up
      end
    end
Vexus
I tried with or but got some errors guess I had to switch the arrow key piece from a number into an input press.

Works splendidly thanks smile.gif

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.