Skip to content

Commit b3a4e0a

Browse files
committed
Docs & Getter
Add getters for 3denabled
1 parent 49c215a commit b3a4e0a

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,8 @@ Returns the file name of the webaudio stream. Usually but not always returns the
155155
``number webaudio:getLooping()``
156156
Returns if the stream is looping, set by setLooping
157157

158+
``number webaudio:get3DEnabled()``
159+
Returns if the webaudio is in 3D mode. This is true by default.
160+
158161
``array webaudio:getFFT()``
159162
Returns an array of 64 FFT values from 0-255.

lua/autorun/webaudio.lua

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,50 +215,56 @@ function WebAudio:GetTimeElapsed()
215215
end
216216

217217
--- Returns the volume of the object set by SetVolume
218-
---- @return number # # Volume from 0-1
218+
--- @return number # Volume from 0-1
219219
function WebAudio:GetVolume()
220220
return self.volume
221221
end
222222

223223
--- Returns the position of the WebAudio object.
224-
---- @return GVector? # # Position of the stream or nil if not set.
224+
--- @return GVector? # Position of the stream or nil if not set.
225225
function WebAudio:GetPos()
226226
return self.pos
227227
end
228228

229229
--- Returns the radius of the stream set by SetRadius
230-
---- @return number # # Radius
230+
--- @return number # Radius
231231
function WebAudio:GetRadius()
232232
return self.radius
233233
end
234234

235235
--- Returns the playtime length of a WebAudio object.
236-
---- @return number # # Playtime Length
236+
--- @return number # Playtime Length
237237
function WebAudio:GetLength()
238238
return self.length
239239
end
240240

241241
--- Returns the file name of the WebAudio object. Not necessarily always the URL.
242-
---- @return string # # File name
242+
--- @return string # File name
243243
function WebAudio:GetFileName()
244244
return self.filename
245245
end
246246

247247
--- Returns the state of the WebAudio object
248-
---- @return number # # State, See STOPWATCH_* Enums
248+
--- @return number # State, See STOPWATCH_* Enums
249249
function WebAudio:GetState()
250250
if self:IsDestroyed() then return STOPWATCH_STOPPED end
251251
return self.stopwatch:GetState()
252252
end
253253

254254
--- Returns whether the webaudio stream is looping (Set by SetLooping.)
255-
---- @return boolean # # Looping
255+
--- @return boolean # Looping
256256
function WebAudio:GetLooping()
257257
return self.looping
258258
end
259259

260+
--- Returns whether the webaudio stream is 3D enabled (Set by Set3DEnabled.)
261+
--- @return boolean # 3D Enabled
262+
function WebAudio:Get3DEnabled()
263+
return self.mode == WebAudio.MODE_3D
264+
end
265+
260266
--- Returns whether the stream is parented or not. If it is parented, you won't be able to set it's position.
261-
---- @return boolean # # Whether it's parented
267+
--- @return boolean # # Whether it's parented
262268
function WebAudio:IsParented()
263269
return self.parented
264270
end

lua/entities/gmod_wire_expression2/core/custom/cl_webaudio.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ desc("setParent(xwa:e)", "Parents the stream position to e, local to the entity.
3333
desc("setParent(xwa:)", "Unparents the stream")
3434
desc("setRadius(xwa:n)", "Sets the radius in which to the stream will be heard in. Default is 200 and (default) max is 1500.")
3535
desc("setLooping(xwa:n)", "If n is not 0, sets the stream to loop. Else stops looping.")
36+
desc("set3DEnabled(xwa:n)", "If n is not 0, sets the stream to be 3D. By default streams are 3D. Else, sets the audio to play directly on clients (mono audio).")
3637

3738
-- is* Getters
3839
desc("isValid(xwa:)", "Returns 1 or 0 for whether the webaudio object is valid (If it is not destroyed & Not invalid from quota)")
@@ -43,6 +44,7 @@ desc("getPos(xwa:)", "Returns the current position of the WebAudio object. This
4344
desc("getVolume(xwa:)", "Returns the volume of the WebAudio object set by setVolume")
4445
desc("getRadius(xwa:)", "Returns the radius of the WebAudio object set by setRadius")
4546
desc("getLooping(xwa:)", "Returns if the stream is looping, set by setLooping")
47+
desc("get3DEnabled(xwa:)", "Returns if the stream's 3D is enabled, set by set3DEnabled")
4648

4749
-- Replicated Clientside behavior on server
4850
desc("getTime(xwa:)", "Returns the playback time of the stream in seconds.")

lua/entities/gmod_wire_expression2/core/custom/webaudio.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ e2function number webaudio:getLooping()
399399
return this:GetLooping() and 1 or 0
400400
end
401401

402+
e2function number webaudio:get3DEnabled()
403+
return this:Get3DEnabled() and 1 or 0
404+
end
405+
402406
__e2setcost(800)
403407
e2function array webaudio:getFFT()
404408
return this:GetFFT(true, 0.08) or {}

0 commit comments

Comments
 (0)