Can you tell me how to make it so that when I hold down the Right mouse button, the procedure works 1 time?

Started by Loriuz on

Topic category: Help with modding (Java Edition)

Last seen on 13:45, 17. Feb 2024
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can you tell me how to make it so that when I hold down the Right mouse button, the procedure works 1 time?
Last seen on 11:45, 7. Oct 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Basically, you need a switch…
Sat, 11/04/2023 - 15:39

Basically, you need a switch that you can turn on or off so the game can keep track of whether the player's already right clicked and is holding down the button, or if they're not currently holding down the button. 

To do this, you'll want to make a player-persistent logic variable. (You can find variables in the right hand side of the main workspace; a player persistent variable is a variable specific to each player that doesn't reset on death.) When the player right clicks with your item, run the procedure, and then set the variable to true. When they're no longer using the item, set the variable back to false. Then, only run the procedure if the variable equals false. This way, once the procedure has run once, the variable will change, and it will then have to reset before it can run again.

Last seen on 13:45, 17. Feb 2024
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry, I'm new to MCreator,…
Sat, 11/04/2023 - 16:17

Sorry, I'm new to MCreator, how do I determine that an item is not being used?