/*------------------------------------------------------------------------------ Thanks for writing this, Chewgum (modified from a proxy by Kilburn) -CBB */------------------------------------------------------------------------------ local PI = 3.1415926535 matproxy.Add( { name = "CarbonVoice", init = function( self, mat, values ) -- Store the name of the variable we want to set self.ResultTo = values.resultvar -- Store other parameters we need self.MinValue = values.min self.MaxValue = values.max self.Type = tonumber(values.type) or 0 self.FreqMul = tonumber(values.freqmul) or 1 self.Phase = tonumber(values.phase) or 0 -- Convert the min and max values into vectors if they are strings if isstring(self.MinValue) and isstring(self.MaxValue) then local x, y, z x, y, z = self.MinValue:match("%[%s*(%S+)%s*(%S+)%s*(%S+)%s*%]") x, y, z = tonumber(x), tonumber(y), tonumber(z) if x and y and z then self.MinValue = Vector(x, y, z) end x, y, z = self.MaxValue:match("%[%s*(%S+)%s*(%S+)%s*(%S+)%s*%]") x, y, z = tonumber(x), tonumber(y), tonumber(z) if x and y and z then self.MaxValue = Vector(x, y, z) end end end, bind = function( self, material, entity ) if (IsValid(entity)) then if (entity:IsPlayer()) then local value = self.MinValue local health = entity:Health() if (health <= 30) then value = math.min(self.MinValue +math.abs(math.sin(CurTime() *2)), self.MaxValue) end local voice_volume = entity:VoiceVolume() if (voice_volume > 0) then value = math.min(self.MinValue +entity:VoiceVolume() *10, self.MaxValue) material:SetFloat(self.ResultTo, value) end --material:SetFloat(self.ResultTo, value) end end end } )