Key Binding code Procedure

Started by Nerea_Love on

Topic category: Help with modding (Java Edition)

Last seen on 17:13, 12. Apr 2024
Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Key Binding code Procedure

I want to do a code with the key bindings for my mod (Minecraft Java 1.20.1, MCreator 2023.4)
The key binding code tat I want to use is *Home Down Down Down Down Down Right Home* to make spawn a entity
I can´t found much information and the bit that I could find it not works for me and I don't know why

Any help?
 

Last seen on 02:33, 27. Apr 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Key bindings, by default,…
Thu, 02/08/2024 - 15:09

Key bindings, by default, are only capable of tracking when a key is pressed and when that same key is released. If you wanted to do a string of keys, you would need some player-lifetime number variables to keep track of how many keys have already been pushed.

Last seen on 17:13, 12. Apr 2024
Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can you do a short tutorial…
Fri, 02/09/2024 - 17:46

Can you do a short tutorial or something?
I dont use much the variables and the tutorials are not very helpful

Last seen on 02:33, 27. Apr 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You need to go to the …
Fri, 02/09/2024 - 23:46

You need to go to the 'variables' menu in the main workspace. On the left hand side of the workspace there should be a tab that says 'variables.' 

Once there, you want to create a new number variable, and name it whatever you want. (I'll call it 'keys pressed.') 

Then, whenever one of your keybinds is pressed, check what number the variable is currently on to know which is the next key that needs to be pushed. (0 means 'home' needs to be pushed, 1 means 'down' needs to be pushed, etc.) If the key that was pressed is correct, increase the variable by one. Otherwise, reset it to zero. When the number reaches its maximum value, you'll know the full key sequence has been entered, and you can run the procedure.