How to cycle functions on one key?

Godot Version

Godot v4.7.2

Question

Sorry if what I’m saying doesn’t make any sense, its sort of difficult to explain.

I’m aiming for a Sierra (shoutout Roberta Williams) style point and click, and I’m hung up on the best way to code swapping the left mouse click function, which I want to be done via right click.

I want to be able to use the left mouse button for the majority of the functions (walk, pick up, touch, etc.) but use the right mouse button to cycle through these functions.

Essentially I want it to look like:

Walk

Right Click

Touch

Right Click

Pick Up

Right Click

Walk

Right now I’m focused on managing just switching between the actions, but I do also want the cursor to reflect which action is selected, and also to be able to select specific actions and items from a drop-down UI.

I’d appreciate any help!

Put enums or string names of actions into an array. Maintain a variable that holds the current action. Implement next_action() function that gets the index of the current action in that array, increment it by one, wrap it around the array length, and assign the current action from the array at the new index.