Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

greeter w memory

Ray Musketeer
Registered User
Join date: 22 Oct 2005
Posts: 418
02-22-2007 23:03
Hi all,
Could sure use some help, brain imploding, ok ,ok, got to have a brain first , I know.. lol.
I once cut & pasted the newbie greeter script , eliminated the newbie part and had a working greeter that wouldn't give a landmark to the same person (till after 24 others got one :-)) . Unfortunately, when I redid my yard I deleted it :-(. Now, I find myself braindead not able to repeat what I once did lol, anyway here's what I got and some of the llowner say's are there just to see if the script was running to that part and not neccesary;



string landmark_name = "";

// how long to wait for the dataserver before giving up
integer DATASERVER_TIMEOUT = 30;

// length of FIFO list of people to remember you already gave to.
integer NAG_LIST_LENGTH = 25;

// channel to communicate to other same objects to let them know you already gave.
integer MULTI_CONTROL_CHANNEL = 861562;

key gDataserveKey = NULL_KEY;
integer gLastCollisionTime = 0;
string gDetectedName;
string gDetectedKey;

list recentlyNagged;




// Add someone to our short-term do-not-nag list
addRecentlyNagged(string name){
if(!wasRecentlyNagged(name)){
recentlyNagged+=name;
if(llGetListLength(recentlyNagged) > NAG_LIST_LENGTH){
recentlyNagged = llDeleteSubList(recentlyNagged,0,0);
}
}
}

// Check if someone is already on our do-not-nag list
integer wasRecentlyNagged(string name){
if(llListFindList(recentlyNagged,[name]) > -1){
return TRUE;
}
return FALSE;
}


default{

state_entry(){
gDataserveKey = NULL_KEY;
gLastCollisionTime = 0;
llListen(MULTI_CONTROL_CHANNEL,llGetObjectName(),"","";);
llOwnerSay ("hello";);
}

listen(integer ch, string name, key id, string msg)

{
llOwnerSay ("hello";);
addRecentlyNagged(msg);

}

collision_start(integer cnt){
integer i;
for(i=0;i<cnt;i++){
string name = llDetectedName(i);
if(!wasRecentlyNagged(name)){
// check if already making a request, or if the request has timed out
if(gDataserveKey == NULL_KEY || (gLastCollisionTime + DATASERVER_TIMEOUT < llGetTime())){
gDetectedName = name;
gDetectedKey = llDetectedKey(0);

addRecentlyNagged(name);
llSay(MULTI_CONTROL_CHANNEL,gDetectedName); // pass the message on not to nag
llOwnerSay ("hello";);

}
}
}
}

dataserver(key req, string data){
if(req == gDataserveKey){
{
llGiveInventory(gDetectedKey,landmark_name);
}

}
gDataserveKey = NULL_KEY; // clear so a new request can be made
}
}
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
02-23-2007 03:37
Firstly - because I'm afraid my brain can't read unformatted code of any great length - lets present the script in a readable form (is this just me or can you people really read unindented code?):

CODE
string landmark_name = "";

// how long to wait for the dataserver before giving up
integer DATASERVER_TIMEOUT = 30;

// length of FIFO list of people to remember you already gave to.
integer NAG_LIST_LENGTH = 25;

// channel to communicate to other same objects to let them know you already gave.
integer MULTI_CONTROL_CHANNEL = 861562;
key gDataserveKey = NULL_KEY;
integer gLastCollisionTime = 0;
string gDetectedName;
string gDetectedKey;
list recentlyNagged;

// Add someone to our short-term do-not-nag list
addRecentlyNagged(string name)
{
if(!wasRecentlyNagged(name))
{
recentlyNagged+=name;
if(llGetListLength(recentlyNagged) > NAG_LIST_LENGTH)
{
recentlyNagged = llDeleteSubList(recentlyNagged,0,0);
}
}
}

// Check if someone is already on our do-not-nag list
integer wasRecentlyNagged(string name)
{
if(llListFindList(recentlyNagged,[name]) > -1)
{
return TRUE;
}
return FALSE;
}


default
{
state_entry()
{
gDataserveKey = NULL_KEY;
gLastCollisionTime = 0;
llListen(MULTI_CONTROL_CHANNEL,llGetObjectName(),"","");
llOwnerSay ("hello");
}

listen(integer ch, string name, key id, string msg)
{
llOwnerSay ("hello");
addRecentlyNagged(msg);
}

collision_start(integer cnt)
{
integer i;
for(i=0;i<cnt;i++)
{
string name = llDetectedName(i);
if(!wasRecentlyNagged(name))
{
// check if already making a request, or if the request has timed out
if(gDataserveKey == NULL_KEY || (gLastCollisionTime + DATASERVER_TIMEOUT < llGetTime()))
{
gDetectedName = name;
gDetectedKey = llDetectedKey(0);

addRecentlyNagged(name);
llSay(MULTI_CONTROL_CHANNEL,gDetectedName); // pass the message on not to nag
llOwnerSay ("hello");
}
}
}
}

dataserver(key req, string data)
{
if(req == gDataserveKey)
{
llGiveInventory(gDetectedKey,landmark_name);
}
gDataserveKey = NULL_KEY; // clear so a new request can be made
}
}
I don't understand what the dataserver Event is doing, or how it gets triggered. I feel the llGiveInventory belongs in the collsion Event were you've detected your new mark.

I also don't see any point in having the script 'talk' to itself... besides, you've already made a call to addRecentlyNagged... so, job done?

So, with the listen, dataserver, and for all practical purposes the state_entry, Events redundant, and the functions not really adding an awful lot... I'm left with something like this:

CODE
string landmark_name = "Test";
integer NAG_LIST_LENGTH = 25;
list recentlyNagged;

default
{
collision_start(integer cnt)
{
integer i;
for(i=0; i<cnt; i++)
{
string name = llDetectedName(i);
llOwnerSay("hello " + name);

if (llListFindList(recentlyNagged,[name]) == -1)
{
// give the landmark
llGiveInventory(llDetectedKey(i), landmark_name);

// maintain the list
recentlyNagged += name;
if(llGetListLength(recentlyNagged) > NAG_LIST_LENGTH) recentlyNagged = llDeleteSubList(recentlyNagged, 0, 0);

llOwnerSay ("here's your lankmark");
}
}
}
}
Please tell me I'm not getting paid based on the number of lines of code I write! :p
Ray Musketeer
Registered User
Join date: 22 Oct 2005
Posts: 418
02-23-2007 07:32
My apologies for unindented code line. That being said I dont read sarcasm well, and please, never refer to me as "you people" :-).

As I mentioned this was a cut & paste from a newbie greeter script the data server line was a remnant of old script checking age of avi didn't need to be there and I thought I had deleted it all. I have several different forms of the same script and should've checked the version I pasted here closer and indented the code because right now I am more bristled with the techy bs language and its hard to be appreciative of any help, not to mention it still doesn't work.
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
02-23-2007 08:54
I'm sorry my reply wasn't more helpful... with reference to the 'you people' this was meant as a jocular aside aimed at all of the long scripts that get posted here with no formatting. It takes me extra time and effort to unravel a long script posted without formatting.

Never-the-less, I apologise for having upset you.

The script should work if an appropriate landmark is included in the inventory of the object. You may have to change the name: "Test", which is the one I used when I tested it.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
Newgy's 10 cents (inflation you know)
02-23-2007 09:37
Pale's scripts are usually on the ball Ray.
The only thing I'd say about this one is that it should pronbably be llSay not llOwnerSay when it gives out the notecard, at least if you want other people to hear it.

Oh and I'd move the say to next to the llGiveInventory but thats cos I like things neat :D

Not sure where the techy bs language comment came from, Pale has been consise and direct with his comments. He used the bare minimum of LSL references to describe how and what he thought needed correcting. If you are put off by someone using the correct terminology then you may be in for a bit fo a rough ride.