[SOLVED] Event coding: How to create an "AND" condition?

I'm trying to fix the movement speed bug for Qmovement diagonal movement.
Basically walking diagonal is way faster (~1.4x) than walking up/down/left/right.
Qmovement.png


So I have to reduce the movement speed only when I walk diagonally.
Basic movement speed is 4.
So a diagonal movement speed of 3 is fine (even if not 100% perfect, but I dont want to use 2,8288...).

So I want to create a common event to fix this and I had something like this in mind:
If Button [Down] is pressed down and Button [Ieft] is pressed down or
If Button [Down] is pressed down and Button [Rlght] is pressed down or
If
Button [Up] is pressed down and Button [Ieft] is pressed down or
If Button [Up] is pressed down
and Button [Rlght] is pressed down
then Script:$gamePlayer._moveSpeed = 3
else Script:$gamePlayer._moveSpeed = 4
​

But well, I don't see anything like an "and" condition.
I tried to put "if" commands into each other, but this doesn't work properly.

(Sometimes the movement speed stays at 3, even if not walking diagonal)

Any other ideas how to fix this?
Switches are your friends in this situation!
For example like this:

Code:
SET Switch verticalMovementButton OFF
SET Switch horizontalMovementButton OFF
SET Switch isMovingDiagonally OFF

IF Button Up is pressed
  SET Switch verticalMovementButton ON
END IF
IF Button Down is pressed
  SET Switch verticalMovementButton ON
END IF
IF Button Left is pressed
  SET Switch horizontalMovementButton ON
END IF
IF Button Right is pressed
  SET Switch horizontalMovementButton ON
END IF

IF verticalMovementButton ON
  IF horizontalMovementButton ON
    SET Switch isMovingDiagonally ON
  END IF
END IF

IF isMovingDiagonally
  $gamePlayer._moveSpeed = 3
ELSE
  $gamePlayer._moveSpeed = 4
END IF

Of course, you may also use JavaScript in an IF condition, but I think practicing the possibilities that pure Eventing already provides is much more efficient.
I'm trying to fix the movement speed bug for Qmovement diagonal movement.
Basically walking diagonal is way faster (~1.4x) than walking up/down/left/right.
View attachment 261037

So I have to reduce the movement speed only when I walk diagonally.
Basic movement speed is 4.
So a diagonal movement speed of 3 is fine (even if not 100% perfect, but I dont want to use 2,8288...).

So I want to create a common event to fix this and I had something like this in mind:



But well, I don't see anything like an "and" condition.
I tried to put "if" commands into each other, but this doesn't work.

Any other ideas how to fix this?
If you're using a script call to set the move speed why not with the button press condition check?

if (Input.isTriggered('up') && Input.isTriggered('right')){
$gamePlayer._moveSpeed = 3;
}
Just to mention it, the direct corollary to what the OP has in the event would be Input.isPressed(), not isTriggered().

Triggered won't continue to run unless you're releasing the button and pushing it again, while Pressed will continue to register as true for as long as you hold it down.
Thanks to all of you. I used the version by Aerosys, because I'm still beginner in "real" scripting.
Its working perfectly.
Thanks to AquaEcho too, now I know how to do an script command like this if I need it again.
And thanks to you ATT_Turan, now I know how I can use the "triggered" state, because in the MV event conditional branch is just "is pressed down" by default.
The "isTriggered()" helps me a lot with cleaning another script where I used "is pressed down" with a timer to prevent multiple activations
This thread is being closed due to being solved. If you would like it reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/solved-event-coding-how-to-create-an-and-condition.157258/