-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFuseBox.gd
70 lines (39 loc) · 1.35 KB
/
FuseBox.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
extends Area
export var whatToDo = "turn off electricity"
var interactedOnce = false
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_Area_body_entered(body):
if body.name == "Player" and not interactedOnce: # hardcoded, whatever
body.enable_interaction(self)
pass
func _on_Area_body_exited(body):
if body.name == "Player":
body.disable_interaction(self)
pass # Replace with function body.
func on_player_interact(player):
print("Player wants to turn off electricity")
var sparkles = get_node("/root/Spatial/Level/1og/wohnzimmer/Sparkles")
var canTurnOff = sparkles.is_visible()
if canTurnOff:
sparkles.hide()
#make lamp passable
var lamp = get_node("/root/Spatial/Level/1og/wohnzimmer/lamp")
for n in lamp.get_children():
lamp.remove_child(n)
n.queue_free()
var dir_light = get_node("/root/Spatial/DirectionalLight")
dir_light.hide()
var sparklesAudio = get_node("/root/Spatial/Level/1og/wohnzimmer/Sparkles/AudioStreamPlayer3D")
sparklesAudio.stop()
player.disable_interaction(self)
interactedOnce=true
else:
$AudioStreamPlayer3D.play()