ChangeLog

12 October 2011

  • Fixed some trash in the init() handler.

25 September 2011

  • Fixed different sound volumes thanks to Marie Nebestanka

Introduction

This script was tested and works on OpenSim version 0.7.4!

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:
/1 jingle on
  • To make the script stop jingling:
/1 jingle off
  • To set the volume (a value from 1 to 10), eg:
/1 jvolume 7
  • To get a quick list of commands:
/1 jhelp

Code

jingle.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, 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);
    }
}

secondlife/jingle.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.