Difference between revisions of "Jingle"

From Second Life Wiki
Jump to: navigation, search
(Undo revision 1165628 by Kira Komarov (Talk)-No Privacy or License issues exist, restoring public content.)
(Replaced content with "{{delete|Privacy issues, lack of time to offer support and ultimately the license clash between Wizardry and Steamworks' GFDL License and Second Life Creative Commons CC-BY-S…")
Line 1: Line 1:
{{LSL Header}}
+
{{delete|Privacy issues, lack of time to offer support and ultimately the license clash between Wizardry and Steamworks' GFDL License and Second Life Creative Commons CC-BY-SA 3.0 which are not compatible. Reference: http://en.wikipedia.org/wiki/GNU_Free_Documentation_License#Compatibility_with_Creative_Commons_licensing_terms}}
 
+
Created by [[User:Kira Komarov|Kira Komarov]].
+
 
+
=ChangeLog=
+
12 October 2011
+
- Fixed some trash in the init() handler.
+
 
+
25 September 2011
+
- Fixed different sound volumes thanks to [[User:Marie Nebestanka|Marie Nebestanka]]
+
 
+
=Introduction=
+
 
+
The script will emit a sound while you are walking. This might be ideal for attached bells, footsteps or whatever you may choose. By default, the script uses the SecondLife built-in bell sound. You can change this by dropping any sound clip in the same primitive where the script resides.
+
 
+
=Motivation=
+
 
+
A script with the same functionality is available on the marketplace for a couple thousand l$. I recreated the script but I have added my own concepts to it. It listens by default on the channel 1, so any commands given to it will have to be issued with /1 prefixed. It also adds a feature to close the channel intermittently to free up resources: when the avatar wearing the primitive containing this script moves, the channel is closed. In order to reopen the channel and make the script accept commands, the avatar has to stand still.
+
 
+
=Setup=
+
 
+
* Create a script in your inventory, choose whatever name you like.
+
* Paste the code below into the script.
+
* Drop the script into the primitive which should emit the sound.
+
* [Optional] Optionally drop a sound clip of your choosing in the same primitive. If the primitive containing the script does not contain a sound clip, the default SecondLife bell sound clip will be used.
+
* [Optional] When standing still, issue /1 jhelp on the main channel to get a list of possible settings.
+
* Walk to hear the sound.
+
 
+
=Supported Commands=
+
 
+
All commands work while you are standing still. You have to type one of these commands on the main chat:
+
 
+
* To turn the jingle on:
+
<pre>
+
/1 jingle on
+
</pre>
+
* To make the script stop jingling:
+
<pre>
+
/1 jingle off
+
</pre>
+
* To set the volume (a value from 1 to 10), eg:
+
<pre>
+
/1 jvolume 7
+
</pre>
+
* To get a quick list of commands:
+
<pre>
+
/1 jhelp
+
</pre>
+
 
+
=Code=
+
 
+
<lsl gremlin="Jingle">
+
//////////////////////////////////////////////////////////
+
// [K] Kira Komarov - 2011, License: GPLv3              //
+
// Please see: http://www.gnu.org/licenses/gpl.html    //
+
// for legal details, rights of fair usage and          //
+
// the disclaimer and warranty conditions.              //
+
//////////////////////////////////////////////////////////
+
+
//////////////////////////////////////////////////////////
+
// --------------------- INTERNALS -------------------- //
+
integer comHandle;
+
integer jingle = 1;
+
integer volume = 10;
+
key sound = "ed124764-705d-d497-167a-182cd9fa2e6c";
+
+
init() {
+
    if(llGetInventoryNumber(INVENTORY_SOUND)) sound = llGetInventoryName(INVENTORY_SOUND, 0);
+
    comHandle = llListen(1, "", llGetOwner(), "");
+
    llOwnerSay("Jingle is now listening on channel 1.");
+
    llOwnerSay("Type /1 jhelp in main chat for a list of commands.");
+
}
+
+
default
+
{
+
    state_entry() {
+
        init();
+
    }
+
+
    on_rez(integer num) {
+
        init();
+
    }
+
+
    changed(integer change) {
+
        if(change & CHANGED_INVENTORY)
+
            llResetScript();
+
    }
+
+
    listen(integer chan,string name,key id,string mes) {
+
        if(id != llGetOwner()) return;
+
        if(mes == "jhelp") {
+
            llOwnerSay("------- START JINGLE COMMANDS -------");
+
            llOwnerSay("To turn the jingle on:");
+
            llOwnerSay("/1 jingle on");
+
            llOwnerSay("To turn the jingle off:");
+
            llOwnerSay("/1 jingle off");
+
            llOwnerSay("To change the jingle volume (from 1 to 10):");
+
            llOwnerSay("/1 jvolume 7");
+
            llOwnerSay("------- END JINGLE COMMANDS -------");
+
            return;
+
        }
+
        if(mes == "jingle on") {
+
            jingle = 1;
+
            llOwnerSay("Jingle is now on.");
+
            return;
+
        }
+
        if(mes == "jingle off") {
+
            jingle = 0;
+
            llOwnerSay("Jingle is now off.");
+
            return;
+
        }
+
        if(llList2String(llParseString2List(mes, [" "], [""]), 0) == "jvolume") {
+
            integer tmpVolume = llList2Integer(llParseString2List(mes, [" "], [""]), 1);
+
            if(tmpVolume < 1) {
+
                volume = 1;
+
                jump say_volume;
+
            }
+
            if(tmpVolume > 10) {
+
                volume = 10;
+
                jump say_volume;
+
            }
+
            volume = tmpVolume;
+
@say_volume;
+
            llOwnerSay("Volume is now: " + (string)volume);
+
            return;
+
        }
+
    }
+
    moving_start() {
+
        if(jingle) llPlaySound(sound, ((float)volume/10.0));
+
        comHandle = llListen(0, "", llGetOwner(), "");
+
    }
+
    moving_end() {
+
        llStopSound();
+
        llListenRemove(comHandle);
+
    }
+
}
+
</lsl>
+
 
+
[[Category:LSL Library]]
+
[[Category:LSL Examples]]
+
[[Category:Gremlin]]
+
[[Category:Wizardry and Steamworks]]
+

Revision as of 00:06, 26 April 2012

Deletion Requested
The deletion of this article was requested for the following reason:

Privacy issues, lack of time to offer support and ultimately the license clash between Wizardry and Steamworks' GFDL License and Second Life Creative Commons CC-BY-SA 3.0 which are not compatible. Reference: http://en.wikipedia.org/wiki/GNU_Free_Documentation_License#Compatibility_with_Creative_Commons_licensing_terms

If there is a need to discuss the deletion of this article, please add your comment(s) here.


@Admin: Please read the discussion before deleting the article.