KesavaKantha Posted April 22, 2015 Share Posted April 22, 2015 I am trying to create a script that triggers sound upon sitting. I tried the "Sat On" script here but it did not work. I am not sure what I'm doing wrong. I would be most grateful for any help. Thank you! Link to comment Share on other sites More sharing options...
Qie Niangao Posted April 23, 2015 Share Posted April 23, 2015 Hmm. Well, that script has an error. Where it checks whether "avatar == NULL_KEY" it means to be testing "sittingAvatar" instead of "avatar" (otherwise the compile will fail with "ERROR : Name not defined within scope"). Also, as written, the script expects a sound file to be in the object's inventory, along with the script. If that's a problem, the script could be changed to reference a sound by UUID instead. Link to comment Share on other sites More sharing options...
KesavaKantha Posted April 23, 2015 Author Share Posted April 23, 2015 Thank you so much for your help! Where would I put the UUID for the sound? (sorry, I am new to scripting) Link to comment Share on other sites More sharing options...
Qie Niangao Posted April 23, 2015 Share Posted April 23, 2015 The first argument to llPlaySound() can be either the name of an embedded sound file (as the script is written now) or the UUID "key" for a sound asset. So, instead of llPlaySound(firstSoundInPrim, 1.0); you could substitute llPlaySound("00000000-0000-0000-0000-000000000107", 1.0); but using your asset's UUID instead of that particular one (which is SND_MUNCH, the sound of eating a LindenWorld bird). Link to comment Share on other sites More sharing options...
KesavaKantha Posted April 23, 2015 Author Share Posted April 23, 2015 I can't tell you how grateful I am for your assistance! It is still not working - here is what I have so far. Does it look okay to you? Not sure where the problem lies. It is one prim, I even tried a script to make the sound play on touch to no avail. vector sit_position = <0.0, 0.0, -0.1>; // here an euler rot vector sit_rotation = <0.0, 0.0, 0.0>; default { state_entry() { llSitTarget(sit_position, llEuler2Rot(sit_rotation * DEG_TO_RAD)); } changed(integer change) { if (change & CHANGED_LINK) { key sittingAvatar = llAvatarOnSitTarget(); // when there's no avatar sitting, stop running code here if (sittingavatar == NULL_KEY) return; string firstSoundInPrim = llGetInventoryName(INVENTORY_SOUND, 0); llPlaySound("2e1d11a8-59fe-caa5-058c-6bb1b64f2d2a", 1.0); } } } Link to comment Share on other sites More sharing options...
Qie Niangao Posted April 23, 2015 Share Posted April 23, 2015 Ah. Yeah, LSL is case-sensitive, so where you have "sittingavatar" you want "sittingAvatar" instead. I should maybe also mention that this sample script is setting a "sit target" in the state_entry section of the script, and it's possible that this will conflict with another script in the object, so we could change this to a simpler approach that doesn't set that target. Or, if this is going to be the only script in the object (no animation on sit), then you may want to change the values for the llSitTarget() call; here's one way to find values for those. Link to comment Share on other sites More sharing options...
KesavaKantha Posted April 23, 2015 Author Share Posted April 23, 2015 It worked! I can't thank you enough for taking the time to help me resolve the issues I was having with this script. I am so grateful for your help! Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now