Basic Second Life scripts: Say one thing, do the other. – Talker and listener object pairs.

Put this script in object A – this is the “button” or “talker” script:

These scripts can be adapted to do a lot of things… An incredible lot of things, in fact, but this specific example rezzes an object from object inventory when another object (from HUD or rezzed) is touched.

It also uses a custom channel, so it doesn’t “suck in” all Local Chat channel (0) messages, which would create lag. Please change the channel number (-1234 in the example) for security reasons.

Create a “talker,” “master,” or the “button” by placing this script into its inventory:

default
{
    state_entry()
    {
        // Use this if you want the trigger to happen when an avatar approaches.
        llSay(-1234, "What To Listen For");
    }

    touch_start(integer total_number)
    {
        // use this if you want to trigger the other script when this object is touched.
        llSay(-1234, "What To Listen For");
    }
}


Put this in object B: This is the main script: the “listener,” or “the slave” object – the thing that DOES what it is told:

// This script rezzes a SPECIFICALLY NAMED OBJECT from the object inventory
// when a specific string is said on the named (numbered) channel

// In addition, you need to say the listened message on the named channel, 
// in this example, /-1234 What To Listen For to trigger this 
// script IN ANOTHER object on the same sim.
// Make another object with the basic script, make the 0 channel /-1234 and make it
// say what you want.

default
{
    state_entry()
    {
        llListen(-1234,"", NULL_KEY, "");
    }
    listen(integer channel, string name, key id, string message)
    {
        if (message == "What To Listen For") {

             llRezObject("SpecificObjectName", llGetPos()+<0,0,0.5>,ZERO_VECTOR,ZERO_ROTATION,0); 
        }
    }
}

These scripts are the simplest things to do, but hardest to find an answer for because they’re SO BASIC. I don’t want you to feel like “fuck it” when you try to ask SL community for scripting help for the very basics, and they tell you smuggly to “figure it out.” Also, I don’t want to waste another hour myself researching which specific way some piece of code was formatted, I’m not going to waste my life LEARNING scripting for fucking Second Life, as much as I love it, just to get a ball to say ‘boink’, so I’m collecting these for myself. You’re welcome to them, too.