@@ -24,13 +24,14 @@ function ENT:Initialize()
24
24
self :SetSolid ( SOLID_VPHYSICS )
25
25
26
26
self .Inputs = WireLib .CreateInputs (self , { " A" , " Toggle" , " Volume" , " Play" , " Stop" ,
27
- " PitchRelative" , " Sample" , " SampleName [STRING]" })
27
+ " PitchRelative" , " Sample" , " SampleName [STRING]" , " Level " })
28
28
self .Outputs = WireLib .CreateOutputs (self , { " Duration" , " Property Sound" , " Properties [ARRAY]" , " Memory" })
29
29
30
30
self .Samples = table .Copy (DefaultSamples )
31
31
32
32
self .Active = false
33
33
self .Volume = 100
34
+ self .Level = 80
34
35
self .Pitch = 100
35
36
self .sound = self .Samples [1 ]
36
37
-- self.sound is a string, self.SoundObj is a CSoundPatch
54
55
1: volume
55
56
2: pitchrelative
56
57
3: duration
58
+ 6: level
57
59
]]
58
60
function ENT :ReadCell (address )
59
61
address = math.floor (address )
@@ -65,6 +67,8 @@ function ENT:ReadCell(address)
65
67
return self .Pitch / 100
66
68
elseif address == 3 then
67
69
return self .Outputs .Duration .Value
70
+ elseif address == 6 then
71
+ return self .Level
68
72
end
69
73
end
70
74
@@ -77,6 +81,7 @@ local cellsOut = {
77
81
[3 ] = " Sample" ,
78
82
[4 ] = " Play" ,
79
83
[5 ] = " Stop" ,
84
+ [6 ] = " Level" ,
80
85
}
81
86
82
87
function ENT :WriteCell (address , value )
@@ -114,6 +119,8 @@ function ENT:TriggerInput(iname, value)
114
119
self :StopSounds ()
115
120
elseif iname == " Volume" then
116
121
self .Volume = math .Clamp (math.floor (value * 100 ), 0.0 , 100.0 )
122
+ elseif iname == " Level" then
123
+ self .Level = math .Clamp (value , 55.0 , 165.0 )
117
124
elseif iname == " PitchRelative" then
118
125
self .Pitch = math .Clamp (math.floor (value * 100 ), 0 , 255 )
119
126
elseif iname == " Sample" then
127
134
function ENT :UpdateSound ()
128
135
if self .NeedsRefresh or self .sound ~= self .ActiveSample then
129
136
self .NeedsRefresh = nil
130
- self .SoundObj = CreateSound (self , self .sound )
137
+ local filter = RecipientFilter ()
138
+ filter :AddAllPlayers ()
139
+ self .SoundObj = CreateSound (self , self .sound , filter )
131
140
self .ActiveSample = self .sound
132
141
133
142
self .SoundProperties = sound .GetProperties (self .sound )
@@ -144,6 +153,7 @@ function ENT:UpdateSound()
144
153
end
145
154
self .SoundObj :ChangePitch (self .Pitch , 0 )
146
155
self .SoundObj :ChangeVolume (self .Volume / 100.0 , 0 )
156
+ self .SoundObj :SetSoundLevel (self .Level )
147
157
end
148
158
149
159
function ENT :SetSound (soundName )
0 commit comments