The interact command would be similar to that of Bedrock's hasitem and scores in syntax terms, but functionally it would allow players to detect when a player in-game has pressed any applicable button on their device.
Parameters:
Button - this determines the button of which a player would interact with on their device (controller/keyboard/mouse). This would be written in "quotations" for clarity, as some buttons may be made up of more than one word (e.g. "Up Arrow").
State - this determines how the button should be interacted with (when left empty, defaults to pressed)
- pressed: the button is actively being held down
- released: the button is not actively being held down
Syntax:
As previously stated, the syntax would emulate hasitem and scores. Here's some examples:
execute as @a[interact={button="any",state=pressed}] at @s run summon lightning ^^^5
- Pressing any button summons lightning 5 blocks in front of the player
execute as @a[interact={button="spacebar"}] at @s run effect @s levitation 10 1 true
- Pressing spacebar gives the player levitation for 10s
execute as @a[interact={button="M1",state=released}] if entity @s[scores={clickTimer=..0}] at @s run scoreboard @s set clickCombo 0
- Not pressing the left mouse button when the player's click timer ends resets their click combo score
This is but a tiny glance into the wonders that is the interact command; a powerful tool that will indubitably make all our lives easier.
Please sign in to leave a comment.
1 Comments