Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Greeting Script

Jim Bunderfeld
The Coder
Join date: 1 Mar 2004
Posts: 161
10-14-2004 17:48
CODE
//////////////////
//By: Jim Bunderfeld
//Made to greet people to certain places
//Date: 10/14/2004
//Open-Source
//////////////////////////////////////////////


string message = "Welcome to Jim's!"; //Insert message here
float range = 20.0; /////How far you want it to search


integer where;
list names;
default
{
on_rez(integer r)
{
names = [""];
llResetScript();
}

state_entry()
{
names = [""];
llSensorRepeat("","",AGENT,range,TWO_PI,1.0);
}
sensor(integer num_detected)
{
integer x;
for(x;x <= num_detected- 1;x++)
{


integer find = llListFindList(names,[llDetectedName(x)]);



if(find < 1)
{


llInstantMessage(llDetectedKey(x),message);
names = names+ [llDetectedName(x)];
}

else
{

}
}



}
}
MSo Lambert
Registered User
Join date: 16 Aug 2004
Posts: 101
10-16-2004 06:15
Just a thought Jim, maybe 0.1 sensor repeat rate is just a waste of resources for a script that greets people. Changing that to 1.0 makes a big difference IMHO.

Alternatively, you might also want to check llVolumeDetect.
_____________________
MSo
eltee Statosky
Luskie
Join date: 23 Sep 2003
Posts: 1,258
10-20-2004 09:45
honestly i'd say a 10 or 15 second sensor would even be preferable

You want to greet people who stop there, not just fly by. And the fewer sensor sweeps per second running in a given sim, the happier the sim will be.
_____________________
wash, rinse, repeat
Gibber Altman
Registered User
Join date: 25 Sep 2004
Posts: 2
11-23-2004 21:24
I prefer to use something like this:
CODE

//Input your message here
string welcomeMessage = "Hello, welcome to KryTec Please enjoy your visit.";


phantomRevert()
{
llSetStatus(STATUS_PHANTOM,TRUE);
llSleep(3);
llSetStatus(STATUS_PHANTOM,FALSE);
}

default
{
state_entry()
{
llSetTexture("701917a8-d614-471f-13dd-5f4644e36e3c",ALL_SIDES);
}
collision(integer c)
{
llSay(0,welcomeMessage);
phantomRevert();
}
collision_start(integer c)
{
llSay(0,welcomeMessage);
phantomRevert();
}
}
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
11-24-2004 18:26
And please don't welcome guests with an Instant Message! llSay or even llWhisper would be much better. I'd hate to have an IM open to which I can't even respond.
Rysidian Rubio
Ruby Red Head
Join date: 14 Jan 2004
Posts: 263
11-24-2004 18:39
Gibber, this is a shorter version of your script that uses less function calls, and does the same thing.
CODE
default
{
state_entry()
{
llVolumeDetect(TRUE); //makes the prim phantom-like but still register collisions
llSetTexture("701917a8-d614-471f-13dd-5f4644e36e3c",ALL_SIDES);
}

collision_start(integer num_detected)
{
if (llDetectedType(0) & AGENT) //only greet avatars, not prims.
{
llSay(0,"Hello, " + llDetectedName(0) +" welcome to KryTec Please enjoy your visit.");
}
}
}
jester Knox
Sculpter of Water
Join date: 22 Apr 2004
Posts: 204
11-25-2004 12:20
or you could do something simpler like

CODE


//rez a prim, dont make it phantom or anything, put it across the door of your shop or
//cover the shop flooe with a cube, make the texture one that is only alpha so it cant be
//seen. whenever someone walks through it it will trigger the say and greet them

default
{
state_entry()
{
llVolumeDetect(TRUE);
}
collision_start(integer num_detected) {
llSay(0, llDetectedName(0) + " welcome to this prim ;-p"); // put whatever you want the greeting to be in here
}
}

_____________________
people tell me my fountains are cool, come check them out at JesAma Fountains, Alviso (190,45) or if you arent in SL try Gigas (secondserver.net) or SLBoutique to shop for my products.
Rysidian Rubio
Ruby Red Head
Join date: 14 Jan 2004
Posts: 263
11-26-2004 13:48
From: DoteDote Edison
And please don't welcome guests with an Instant Message! llSay or even llWhisper would be much better. I'd hate to have an IM open to which I can't even respond.


IM's recieved from objects don't open a new IM window, they appear just as local chat but only you recieve the message, and they are in a different colour, the same as local chat spoken by an object. So really in some cases an IM from an object is better because it causes less spam to others in the vicinity.
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
11-28-2004 19:28
Yes, I realized that soon after I posted when I remembered that the Av RADAR must use IMs. But, then I loaded up Half-Life 2 and forgot about SL and my errant post for the next 8 hours. Sorry.
Korg Stygian
Curmudgeon Extraordinaire
Join date: 3 Jun 2004
Posts: 1,105
12-06-2004 04:03
This is an interesting little script that has an application I need to extend and I can't script worth anything. Hopefully someone will accept the following "challenge" and help me/the community out here as I think this application might "go widespread" if the "challenge" is accepted and the code written.

The initial "problem" - already described in this thread - greeting an av upon entry.
The extended "problem challenge" -
---a. Determining the direction of movement of the av into or out of the structure
---b. Applying/branching to the appropriate entry or exit message - instead of welcome, goodye for instance.

So that there is a specific context, in my case, I want to apply this to a doorway which leads to my aircraft carrier island from the flight deck. Upon exiting the island, I want to warn visitors to watch out for prop wash and jet blast... Simple, cutesy saftey warning I know. OTOH, I will figure out an appropriate "welcome/status of the carrier island operations" message if entering from the flight deck.

Anyone?

Obviously, the extended applications are limitless... including greeting people as they go from floor to floor in a mall/building, offering goodbye messages in the same manner... making certain "areas" of a build seem alive by having the "buiild" apparently talk to the avatar (random messages or pointed ones - but that is yet another extension of this idea)...

Thanks in advance.

And thanks for posting this already in the library.
Rysidian Rubio
Ruby Red Head
Join date: 14 Jan 2004
Posts: 263
12-06-2004 15:52
This isn't as hard as it may seem. Using a similar script as the one above, but 2 linked prims instead of 1, set to llVolumeDetect, could be used, 1 for avatars entering the build, the other for avatars exiting the build. they'd link_message the other prim to say "i saw him first, so he's entering, don't send him a message" well sort of.

There would be a much easier way by which you'd detect the velocity of the avatar when then entered/exited and determine that way their direction of movement, but I suck at vectors so couldn't help there.

I'll post the scripts needed to do the first option unless someone beats me to it or something better.