Transmitting Sound

How might I hook into gmod and do the following.

Make a an entity that looks like a can.
Then take all the sounds it picks up, at their sound strength.

The transmit them syncronously to another entity, a barrel, as a speaker.

Think how you can hear sound through portals in portal.
I am working on a portal gun remake.
Please help.


Didn’t even know you could hear sounds through portals.

My only guess at this would be to create a env_microphone and a corresponding info_target. I’m not sure if it will work though.

Sorry, I was a little vague on the details.
This is my first thread, Im new to lua, but know Java.
How might I hook into the base source engine entities?

ents.Create can create (almost?)any entity. Make sure you look at the other entity metamethods as well for setting keyvalues and such.

If will work, I have made a tool that does this before.

[editline]20th September 2014[/editline]

There might be limitations though.

[editline]20th September 2014[/editline]

IMHO you should be working on a portal gun if you are new to Lua and Source Engine, start small, familiarize yourself with how Source Engine works, etc, then you can start on more serious/ambitious projects.

I may be new to lua.
But I know enough about it, and the source engine.
I am just confused.
The env_microphone can be spawned and linked to a info_target.
Two questions,
What outputs that sound? env_speaker?
And how would I link them using lua?
That seems a little hard to do.
I have neer done THAT before.

Also, Ill take any code you have.
I just want sound, doesnt matter what it picks up.

The links mcd posted give you all the info you need. Create the entities, set the key values( You can find the actual key value names in .fgd files, base.fgd, hl2.fgd, just google), :Spawn(), parent to the visibe entities or just set pos if they are stationary.

Fair enough.

Although, what is the speaker?

Mic to link to ? = Mic and Speaker?

info_target is the speaker, env_microphone is the mic, obviously.

You must create the speaker before the microphone. Assign a targetname to the speaker, create the mic and assign the targetname to mic keyvalue ( i dont remember what it is called exactly )

If you would of read even just the top part of the env_microphone page you would of seen the:

Speaker target <targetname>
The name of an info_target at which to play any sounds heard by this microphone. If specified, the microphone will consider itself in Speaker mode.
      Warning:    Cannot be an env_speaker!


Also you’re not going to learn lua by ‘taking any code you have (to offer)’. You’re going to need to create the entites with ents.Create then set their position and keyvalues then call the Spawn method on the new entity. The wiki will answer any questions you might have regarding that. THIS site will also help you search for functions if you’re having trouble finding them.

Good luck. Right now you might just want results and feel like copy/pasting code but if you take the time to learn how to do it yourself then you’ll enjoy programming much more.

I do not “copy and paste”.
I am an experienced Java programmer.
I just asked how the hell lua would interface with it.

EDIT: And by it, the source engine entities.

You’d use the Entity:Fire( ) function.

Actually this function I believe, not the previous one.

Thanks Jeezy.
Thank you others for pointers.