Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Script Help

Kanji Zeplin
Registered User
Join date: 15 May 2009
Posts: 3
06-23-2009 01:57
Ok basically what i am trying to do is have a object greet visitors by name as they come within a 20 meter range, but remember who it has greeted, and not greet them again for an hour. I want to be able to attach this item to myself.

Example what to say: "Welcome Kanji to my place" Example of what is said now: "Welcome to my place"

The first example is what i want it to say, the 2nd is what it currently says, i can no figure out how to make it say the persons name. Here is the code i got so far, i have tried diff commands such as +ava + and +n +, as i am new to scripting i have used those on a couple other scripts for it to relate to people, but it does not seem to work here:

list recent_avatars;
integer chan;
integer n;
integer ava;
add_avatar(string name) {
if(!seen(name)) {
recent_avatars += name;
if (llGetListLength(recent_avatars) > 25) {
recent_avatars = llDeleteSubList(recent_avatars,0,0);
}
}
}
integer seen(string name) {
if(llListFindList(recent_avatars,[name]) > -1) { return TRUE; }
return FALSE;
}


default
{
state_entry() {
llSensorRepeat("", NULL_KEY, AGENT, 20, PI, 5);
}
sensor(integer total_number) {
if(!seen(llDetectedName(0))) {
// speak out loud!
llSay(0,"weclome to my place";);

add_avatar(llDetectedName(0));
}
}

}
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
06-23-2009 02:51
You just need to store the name in the sensor event so you can reuse it.

Make your sensor event something like this.


sensor(integer total_number) {
string currentName = llDetectedName(0); // Store the name.
if(!seen(currentName)) {
// speak out loud!
llSay(0,currentName + " weclome to my place";);

add_avatar(currentName);
}
}
Kanji Zeplin
Registered User
Join date: 15 May 2009
Posts: 3
Timer?
06-23-2009 10:45
Ok changing the sensor worked out great, thanks. Is there a way to make it greet people only every hour if they are currently there? And is there a way to make it read the text from a notecard instead of having to tell people how to edit it?
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
06-23-2009 11:02
From: Kanji Zeplin
if (llGetListLength(recent_avatars) > 25) {
recent_avatars = llDeleteSubList(recent_avatars,0,0);
}

Unless you really only want to keep the last 25, I'd do something more like:

if (lllGetFreeMemory() < 2000)
{
recent_avatars = llDeleteSubList(recent_avatars,0,0);
}

From: someone
Is there a way to make it greet people only every hour if they are currently there? And is there a way to make it read the text from a notecard instead of having to tell people how to edit it?

As long as they haven't been pulled off the recent_avatars list, they won't get greeted again at all!

As for reading text from a notecard, it's a little tricky for new scripters but not that horrible.. You'll need to use llGetNotecardLine and the dataserver event. More at http://wiki.secondlife.com/wiki/Category:LSL_Dataserver.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Kanji Zeplin
Registered User
Join date: 15 May 2009
Posts: 3
well...
06-23-2009 11:13
Well i would like it to greet people if they show up again later on.. I dont want it to just greet once ever.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
06-23-2009 11:18
Just IMO but I'd rather not get greeted more than once a month, if at all. Maybe I'm just old and jaded but a sign saying howdy would be nicer than scripted chat.

To put a time limit on it, you'll need to either add another list that keeps track of times or change the existing recent_avatars to include both the keys and times.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-23-2009 18:35
if you store both the time the av was first detected and the av's name, you can check the list of times when you do your timer call to the sensor, and remove any names that were detected more than your limit ago

PS (you can dynamically set the list size safely by checking llGetFreeMemory and setting the current list length as your max... that's prevent if from blowing up in either MONO or LSO)

if I get time to look I'll throw up an example of how to limit those lists and times efficiently
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-25-2009 09:01
https://wiki.secondlife.com/wiki/User:Void_Singer/Programs#v7-D_Advanced_Visitor_Greeter

single object version, I used a llSensor + timer combo because it's makes it easy to tweak the script to use either a Compound Sensor (multiple arcs for max returns from a single prim) or multiple sensors in other objects (for big locations, sensors at different locations reporting back)

it keeps separate lists for avs and when they were greeted. preferable since the list find function only has to search half as many entries when adding to the list or culling, and there's no need to convert to strides.

it forces redetected Avs to the front of the list so that any av that returns before a culling cycle isn't regreeted, (also so they are less likely to drop off the end before returning. a free frequent visitor bonus.. less spam)

it's annotated so that you can remove certain sections like the Dynamic Memory Limitation, or even the Av Culling (which customers Like Meade and I will GREATLY appreciate)

someone will recognize the implication of what the script can be used to do.. I just don't care anymore =P
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -