Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Scripting sound clip in object to a key (ala car horn via H key)

Khanaar Ingmann
KCC Motors Owner
Join date: 8 Nov 2005
Posts: 7
12-11-2005 22:42
I was wondering, after doing some searching in this forum, i didnt come with anything... What I wonder is, can i attatch a sound file (say a horn) to a driving car model, and map the sound trigger to a keyboard key, say key H?
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
12-12-2005 03:19
No, but you could create it as a gesture and attach it to one of the F keys.

llTakeControls() is the thing that lets us intercept key presses, and it only takes a limited number of entries as you can see.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
12-12-2005 03:39
You could attach it to the left mouse button if you're not using that.
Hunter Stern
Web Weaver
Join date: 7 Oct 2004
Posts: 377
12-12-2005 22:22
you mean you couldn't add teh following script to a prim?

CODE
default
{
state_entry()
{
llPreloadSound("CarHorn");
llPreloadSound("Beep"); //Preload the Sound file named CarHorn (as an example)
llListen(0, "", llGetOwner(), "");
}

listen(integer channel, string name, key id, string message)
{
integer gCmdChannel = 0;
if (message == "h")
llTriggerSound("CarHorn", 5.0);
{
else if (message == "b")
llTriggerSound("Beep", 5.0);
{
//llResetScript();
}
}
}


seems all you need is a simple listen script, I trigger sounds on key all the time (unless that wasn't the question)
Kage Seraph
I Dig Giant Mecha
Join date: 3 Nov 2004
Posts: 513
12-13-2005 06:55
I disagree. One could certainly map a key input to triggering a sound-- it is just that we can map so few keys that there are often none available. One option would be to map a multiple key input to the trigger.

For example, I ran out of mappable keys on a plane I'd been working on awhile back, so the toggle for hover and flight modes was hitting both FWD and BACK at the same time. Worked pretty well.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
12-13-2005 12:13
why not just make a gesture?
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Hunter Stern
Web Weaver
Join date: 7 Oct 2004
Posts: 377
12-13-2005 16:43
.