@@ -26,8 +26,12 @@ E2Lib.registerConstant( "WA_FFT_DELAY", 80 ) -- Delay in ms
2626
2727
2828registerType (" webaudio" , " xwa" , WebAudio .getNULL (),
29- nil , -- TODO: webaudios in io?
30- nil ,
29+ function (self , input )
30+ return input
31+ end ,
32+ function (self , output )
33+ return output
34+ end ,
3135 function (ret )
3236 -- For some reason we don't throw an error here.
3337 -- See https://github.com/wiremod/wire/blob/501dd9875ab1f6db37a795e1f9a946d382db4f1f/lua/entities/gmod_wire_expression2/core/entity.lua#L10
@@ -46,6 +50,24 @@ local function registerStream(self, url, owner)
4650 return stream
4751end
4852
53+ e2function string toString (webaudio stream )
54+ if IsValid (stream ) then
55+ return string.format (" WebAudio [%d]" , stream .id )
56+ else
57+ return " WebAudio [null]"
58+ end
59+ end
60+
61+ e2function string webaudio :toString () = e2function string toString (webaudio stream )
62+
63+ WireLib .registerDebuggerFormat (" WEBAUDIO" , function (stream )
64+ if IsValid (stream ) then
65+ return string.format ( " WebAudio [Id: %d, volume: %d%%, time: %.02f/%d]" , stream .id , stream .volume * 100 , stream .stopwatch :GetTime (), stream .length )
66+ else
67+ return " WebAudio [null]"
68+ end
69+ end )
70+
4971__e2setcost (1 )
5072e2function webaudio operator = (webaudio lhs , webaudio rhs ) -- Wa = webAudio("...") (Rip Coroutine Core comments)
5173 local scope = self .Scopes [ args [4 ] ]
294316__e2setcost (15 )
295317e2function void webaudio :destroy ()
296318 -- No limit here because they'd already have been limited by the creation burst.
319+ local owner = this .owner or self .player
320+ -- Prevent people destroying others streams and getting more slots? Would be weird.
297321 if this :Destroy () then
298- local ply = self .player
299- StreamCounter [ply ] = StreamCounter [ply ] - 1
322+ StreamCounter [owner ] = StreamCounter [owner ] - 1
300323 end
301324end
302325
0 commit comments