From f4be67996a7009d94670d51033cdc6a6d8085b42 Mon Sep 17 00:00:00 2001 From: derek Date: Thu, 7 Nov 2024 17:00:50 -0600 Subject: [PATCH] doors are now assigned via door script --- assets/blockout_2.tscn | 3 +-- levels/switchcontroller.gd | 36 +++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/assets/blockout_2.tscn b/assets/blockout_2.tscn index 589d55c..0269e85 100644 --- a/assets/blockout_2.tscn +++ b/assets/blockout_2.tscn @@ -1943,9 +1943,8 @@ transform = Transform3D(0.015, -7.86969e-07, 2.74274e-07, 7.86945e-07, 0.015, 1. mesh = SubResource("ArrayMesh_dt3jf") skeleton = NodePath("") -[node name="Switch 1" type="Node" parent="." node_paths=PackedStringArray("door")] +[node name="Switch 1" type="Node" parent="."] script = ExtResource("32_dncpy") -door = NodePath("Door1") [node name="Door1" type="MeshInstance3D" parent="Switch 1" node_paths=PackedStringArray("anim_player")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 28.5934, 14.0814) diff --git a/levels/switchcontroller.gd b/levels/switchcontroller.gd index 618e4f6..2bc7069 100644 --- a/levels/switchcontroller.gd +++ b/levels/switchcontroller.gd @@ -1,8 +1,7 @@ extends Node -@export var door : Node - var switches = [] +var doors = [] var switch_override : Node # Called when the node enters the scene tree for the first time. @@ -17,6 +16,8 @@ func _ready() -> void: switch_override = i else: switches.append(i) + if i.is_in_group("door"): + doors.append(i) #print("switches " + str(switches)) #print("override switches " + str(switch_override)) @@ -34,27 +35,32 @@ func _on_switch_changed() -> void: print("null check passed") if switch_override.switched_on: print("switched on") - if door.door_open == false: - door.open() - else: - if door.door_open == true: - door.close() + for i in doors: + if i.door_open == false: + i.open() + else: + if i.door_open == false: + i.open() #Otherwise follow standard switches elif switches_on == switches_needed: print("switch check run with " + str(switches_on) + "switches on") - if door.door_open == false: - door.open() + for i in doors: + if i.door_open == false: + i.open() else: print("switch check run with " + str(switches_on) + "switches on") - if door.door_open == true: - door.close() + for i in doors: + if i.door_open == true: + i.close() #Otherwise follow standard switches elif switches_on == switches_needed: print("switch check run with " + str(switches_on) + "switches on") - if door.door_open == false: - door.open() + for i in doors: + if i.door_open == false: + i.open() else: print("switch check run with " + str(switches_on) + "switches on") - if door.door_open == true: - door.close() + for i in doors: + if i.door_open == true: + i.close()