Jump to content

Sound emitter and Volume menu.


AggrorJorn
 Share

Recommended Posts

I have this sound menu in my project and you can set the volume for 3 different sound sliders. The sound volume is nicely stored in a variabele but now I need to get this variable to work with ingame sound emitters.

 

I copied the sound emitter entity and added a menu for choosing the sound group.

post-45-057574400 1284299617_thumb.jpg

 

 

The problem is how to efficiently get the variables that contain the sound volume for each group to the sound emitter (gameVolume, musicVolume, speechVolume). I came up with the following but that, in the first place, doesn't work and it seems a bit redundant to let the emitter update itself constantly. Any ideas?

 

function object:Update()
	local soundgroup = self.model:GetKey("soundgroup")	

	if gameVolume ~= nil then	
		if soundgroup == "Game sound" then
			object.model:SetKey("volume",gameVolume:ToNumber())
		end
	end

	if musicVolume ~= nil then
		if soundgroup == "Music and ambient" then
			object.model:SetKey("volume",musicVolume:ToNumber())
		end
	end

	if speechVolume ~= nil then
		if soundgroup == "Speech" then
			object.model:SetKey("volume",speechVolume:ToNumber())
		end
	end
end	

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...