Davis Woolley
Registered User
Join date: 26 Dec 2006
Posts: 23
|
03-19-2007 14:16
What I am looking to do is have an object that when worn will listen for "/cough" in the chat box and play an animation and sound. I think I have the first bit of scripting done, but I have no idea where to go from here. Please send me recommendations or examples if you have ideas; I would prefer to finish the script myself. My current script is: default { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); } run_time_permissions (integer perm) { if (PERMISSION_TRIGGER_ANIMATION & perm) { llPlaySound("1.5cough", 1); llStartAnimation("Coughing"  ; } } }
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
03-19-2007 14:42
Broadly, for a script to 'hear' chat you need to set up a listen filter using llListen, and have a listen Event Handler. Currently, your script will play its sound, and run its animation, once only in response to the permissions request: lRequestPermissions
|
Davis Woolley
Registered User
Join date: 26 Dec 2006
Posts: 23
|
03-20-2007 06:39
Thanks much, I have revised the object to listen for the command in chat and it works great... but now the animation doesn't play. Maybe I'm using the wrong script to run the animation. Here is the new script: default { state_entry() { llListen(0,"",llGetOwner(),""  ; } listen(integer channel, string name, key id, string message) { if (llToLower (message) == "/cough"  { llPlaySound("coughing", 1); llStartAnimation("Coughing"  ; } } } As stated before, the sound plays fine, but the animation does not. Also, thank you Pale, for sending me links to the information rather than rewriting the script for me. This is invaluable to me as a new scripter.
|
Davis Woolley
Registered User
Join date: 26 Dec 2006
Posts: 23
|
03-20-2007 06:43
lol, ah, I had to combine the two scripts to get it to work. Here is the finished script for my handkerchief that makes you cough: default { state_entry() { llListen(0,"",llGetOwner(),""  ; llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); } listen(integer channel, string name, key id, string message) { if (llToLower (message) == "/cough"  { llPlaySound("coughing", 1); llStartAnimation("Coughing"  ; } } } Thanks for the help Pale.
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
03-20-2007 12:23
From: Davis Woolley Also, thank you Pale, for sending me links to the information rather than rewriting the script for me. This is invaluable to me as a new scripter. You're welcome. I think people do generally try and give an appropriate level of help - although different folk do have different expectations of 'help'.  Your code... default { state_entry() { llListen(0,"",llGetOwner(),""); llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); }
listen(integer channel, string name, key id, string message) { if (llToLower (message) == "/cough") { llPlaySound("coughing", 1); llStartAnimation("Coughing"); } } } ...one small observation. If you give the scripted object to a new owner it's not going to work. The state_entry Event Handler is a one-time only deal. It will only run following a script reset. Therefore, the llListen and llRequestPermissions will be stuck with the last owner to reset the script. You might be interested to look at the changed Event Handler paying particular attention to CHANGED_OWNER. This gives the script the opportunity to realign itself to a new owner. Note: When posting scripts on the forums, use the PHP tags. These tags cause scripts to keep indentation and have syntax highlighting. You type: [PHP]Your script here[/PHP]
|
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
|
03-20-2007 12:57
Just create a gesture and be done with it. Much more effective.
|