Fixed switch override

if/else tab error stupid
This commit is contained in:
derek
2024-10-14 13:28:37 -05:00
parent 735a48b21d
commit 784a9865ab
2 changed files with 21 additions and 14 deletions

View File

@@ -380,10 +380,9 @@ script = ExtResource("13_v1s63")
shape = SubResource("SphereShape3D_vyys8")
[node name="switch3" parent="Door1" groups=["interact", "switch_override"] instance=ExtResource("10_lktr8")]
transform = Transform3D(1.655, 0, 0, 0, 1.655, 0, 0, 0, 1.655, 4.27439, 2.00195, -23.9803)
transform = Transform3D(1.655, 0, 0, 0, 1.655, 0, 0, 0, 1.655, 4.55934, 1.62823, -22.3877)
skeleton = NodePath("../..")
script = ExtResource("15_0sc55")
toggle_enabled = true
[node name="StaticBody3D" type="StaticBody3D" parent="Door1/switch3" groups=["interact", "switch"]]
collision_layer = 3

View File

@@ -18,6 +18,9 @@ func _ready() -> void:
else:
switches.append(i)
print("switches " + str(switches))
print("override switches " + str(switch_override))
func _on_switch_changed() -> void:
var switches_needed = switches.size()
@@ -27,17 +30,22 @@ func _on_switch_changed() -> void:
switches_on += 1
#First check override switch and open or close door
if switch_override.switched_on:
if door.door_open == false:
door.open()
else:
if door.door_open == true:
door.close()
if switch_override != null:
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()
#Otherwise follow standard switches
elif switches_on >= switches_needed:
if door.door_open == false:
door.open()
else:
if door.door_open == true:
door.close()
elif switches_on == switches_needed:
print("switch check run with " + str(switches_on) + "switches on")
if door.door_open == false:
door.open()
else:
print("switch check run with " + str(switches_on) + "switches on")
if door.door_open == true:
door.close()