Skip to content

Commit

Permalink
add input tracking script and update Player scene to include it
Browse files Browse the repository at this point in the history
  • Loading branch information
sebashtioon committed Nov 7, 2024
1 parent 5400c42 commit 2717b9b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
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())
4 changes: 3 additions & 1 deletion Scenes and Scripts/Scenes/Player/Player.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=42 format=3 uid="uid://cjm5lrxicdgsf"]
[gd_scene load_steps=43 format=3 uid="uid://cjm5lrxicdgsf"]

[ext_resource type="Script" path="res://Scenes and Scripts/Scenes/Player/Player_SCRIPT.gd" id="1_5mhs1"]
[ext_resource type="Script" path="res://Textures/Icons/Script Icons/Scripts/CameraIcon_SCRIPT.gd" id="2_37tst"]
Expand All @@ -24,6 +24,7 @@
[ext_resource type="StyleBox" uid="uid://com3tix0pshhk" path="res://Resources/Styles and Themes/Styles/Default/Label/Default_Label.tres" id="19_nviyp"]
[ext_resource type="Script" path="res://Scenes and Scripts/Scenes/Player/Settings/Volume/MusicSlider_SCRIPT.gd" id="20_124b5"]
[ext_resource type="Script" path="res://Scenes and Scripts/Scenes/Player/Settings/Volume/SFXSlider_SCRIPT.gd" id="21_fi5yi"]
[ext_resource type="Script" path="res://Scenes and Scripts/Scenes/Player/Debug/inputs_currently_pressing_SCRIPT.gd" id="25_h5s3l"]

[sub_resource type="CapsuleMesh" id="CapsuleMesh_w6tro"]

Expand Down Expand Up @@ -991,6 +992,7 @@ grow_vertical = 0
theme = ExtResource("17_rhxkt")
horizontal_alignment = 1
vertical_alignment = 1
script = ExtResource("25_h5s3l")

[connection signal="timeout" from="AutoSaveTimer" to="." method="_on_auto_save_timer_timeout"]
[connection signal="area_entered" from="Head/Camera3D/InventoryLayer/Boundary" to="." method="_on_boundary_area_entered"]
Expand Down

0 comments on commit 2717b9b

Please sign in to comment.