Power, activated and deactivated by a key on the keyboard

Started by zorualeloupsolitaire on

Topic category: Help with Minecraft modding (Java Edition)

Joined Nov 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Power, activated and deactivated by a key on the keyboard

Hello,

I have searched on Mcreator and on the internet, without success, for a tutorial that explains how to check if a player has pressed a button.

I'd like to make a power boost, which activates when the player presses a button, for example K.
The player would receive enhanced strength, speed and jumping boosts. But I don't want him to have to hold down the K button constantly.

Does anyone know how to make it so that the player only needs to press once to activate the power boost and a second time to deactivate it?

Thank you!

Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You could have the power…
Thu, 01/02/2025 - 17:46

You could have the power boost be active when a player_lifetime logic variable is true for them?

Detect when K is pressed using a Key Binding element, then assign a procedure to the On key pressed trigger.
Inside the procedure, you would set your variable to true if it is currently false, and false if it is currently true.

Joined Nov 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you for your help, I…
Thu, 01/02/2025 - 18:27

Thank you for your help, I simply have a problem. Now my launcher won't launch at all.

Do you have a solution? Here's what I did.

Variable

Procedure Tick update

 

Procedure Key pressed

Joined Nov 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hey, so my game's going…
Thu, 01/02/2025 - 18:57

Hey, so my game's going really well now. It was PlayerAnimator, which made me crash.

Now I've got another problem: the command doesn't work.

Joined Nov 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
So my fault, I've just…
Thu, 01/02/2025 - 19:02

So my fault, I've just realized that I'd set the wrong variable on one of the commands. Now it's working fine!

Thanks again!