-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add input tracking script and update Player scene to include it
- Loading branch information
1 parent
5400c42
commit 2717b9b
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
Scenes and Scripts/Scenes/Player/Debug/inputs_currently_pressing_SCRIPT.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
extends Label | ||
|
||
var pressed_inputs = {} | ||
|
||
func _process(_delta): | ||
# List of actions to check | ||
var actions = [ | ||
{"name": "Jump", "action": "Jump"}, | ||
{"name": "Move Forward", "action": "move_forward"}, | ||
{"name": "Move Backward", "action": "move_backward"}, | ||
{"name": "Move Left", "action": "move_left"}, | ||
{"name": "Move Right", "action": "move_right"}, | ||
{"name": "Quit", "action": "Quit"}, | ||
{"name": "Sprint", "action": "Sprint"}, | ||
{"name": "Reset", "action": "Reset"}, | ||
{"name": "Exit", "action": "Exit"}, | ||
{"name": "Inventory", "action": "Inventory"}, | ||
{"name": "Inventory Click", "action": "inventory_click"}, | ||
{"name": "Crouch", "action": "Crouch"}, | ||
{"name": "Save Game", "action": "SaveGame"}, | ||
{"name": "Interact", "action": "Interact"} | ||
] | ||
|
||
# Update the set of pressed inputs based on current state | ||
for action_data in actions: | ||
var action_name = action_data["name"] | ||
var action = action_data["action"] | ||
|
||
if Input.is_action_pressed(action): | ||
pressed_inputs[action_name] = true # Add or keep in the set | ||
else: | ||
pressed_inputs.erase(action_name) # Remove from the set if not pressed | ||
|
||
# Update the label's text with a comma-separated list of pressed inputs | ||
self.text = ", ".join(pressed_inputs.keys()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters