Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Reading an allow list for a door

Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
07-05-2006 11:13
I am having trouble with this allow list.
It only lets the person in who is first on the list. What am I doing wrong? Why is it not looking for everyone on my allow list?

CODE

key usernc;
integer userncline;

default
{

dataserver(key id, string data)
{
if( id == usernc ) {
if( data != EOF ) {
users += [llToLower(data)];
lineNum++; // Go read the next line
llWhisper(0,(string)users);
llGetNotecardLine("allowlist", lineNum);
}
}
}


state_entry()
{
usernc = llGetNotecardLine("allowlist", userncline);
}

touch_start(integer total_number) //if the list is empty or the owner touched it or the list says 'everyone' or the user is on the list...then do stuff!
if (llGetListLength(users) == 0 || llDetectedKey(0) == llGetOwner() || usernc == "everyone" || llListFindList(users, [llToLower(userName)]) != -1)
{
//Do stuff with the door
}
else
{
llWhisper(0, "You cannot use this door.");
}
}
}


Another thing that is happening is that when I type "everyone" on my notecard, it will not work. When I output the value of usernc, it's a key. So I tried putting

users == "everyone" but I get an error.
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
07-05-2006 11:57
1. users is never declared. Is it supposed to be a list?
2. lineNum is never declared.

3. When the script checks for "everyone", I am assuming that it would be the only line in the notecard, in which case you should end up with a list of length 1, so you would have to use llList2String(users, 0) to compare rather than "usernc" or "users"

4. Why are you only defining usernc the first time you read the notecard? I'm assuming that you need to usernc= when you read from it in the dataserver event. Otherwise, your check of "id==usernc" is probably only happening once (I'm not sure on this one, I have not messed much with the notecard reading events).
Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
07-05-2006 12:25
ok, troubleshooting....
How do I get the script to whisper each line of the notecard? When I do

llWhisper(0,(string)users);

I am just getting the first line. So obviously it's not reading the entire notecard. How can I get it to read all of the lines?
_____________________
-Please don't feed the troll.
It feeds on your responses.
It stays here because you give it a place to dwell.
It lives because you continue to breathe life into it.

-This is YOUR WORLD and YOUR IMAGINATION
(not Her World and Her Imaginiation)!
Travis Lambert
White dog, red collar
Join date: 3 Jun 2004
Posts: 2,819
07-05-2006 13:01
I'm at work, so I can't test this as fully as I'd like, but I believe this is what you want:

CODE
key usernc;
integer userncline;

default
{

dataserver(key id, string data)
{
if( id == usernc )
{
if( data != EOF )
{
users += [llToLower(data)];
lineNum++; // Go read the next line
llWhisper(0,(string)users);
usernc = llGetNotecardLine("allowlist", lineNum);
}
}
}


state_entry()
{
usernc = llGetNotecardLine("allowlist", userncline);
}

touch_start(integer total_number) //if the list is empty or the owner touched it or the list says 'everyone' or the user is on the list...then do stuff!
{
if (llGetListLength(users) == 0 || llDetectedKey(0) == llGetOwner() || usernc == "everyone" || llListFindList(users, [llToLower(userName)]) != -1)
{
//Do stuff with the door
}
else
{
llWhisper(0, "You cannot use this door.");
}
}
}




Essentially, I think the problem seems to be in your dataserver event, when you're calling another llGetNotecardLine. You're not setting usernc to the new event key. As a result, its failing your IF condition.
_____________________
------------------
The Shelter

The Shelter is a non-profit recreation center for new residents, and supporters of new residents. Our goal is to provide a positive & supportive social environment for those looking for one in our overwhelming world.
Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
07-05-2006 13:41
It seems like 'users' (which is actually declared as a list in my sript - I forgor to paste it) is not anywhere in there. I tried this:

llListFindList((list)MyAllowedUsers, [llToLower(UserName)]) != -1)

But it does not work either. If I am going to use llListFindList in the if statement, there should be a list somewhere which there isn't, right? Am I supposed to decalre a list somehow in the dataserver event?

It seems like I am looking for the UserName in a list that does not exist.
Travis Lambert
White dog, red collar
Join date: 3 Jun 2004
Posts: 2,819
07-05-2006 14:27
From: Over Sleeper
It seems like 'users' (which is actually declared as a list in my sript - I forgor to paste it) is not anywhere in there. I tried this:

llListFindList((list)MyAllowedUsers, [llToLower(UserName)]) != -1)

But it does not work either. If I am going to use llListFindList in the if statement, there should be a list somewhere which there isn't, right? Am I supposed to decalre a list somehow in the dataserver event?

It seems like I am looking for the UserName in a list that does not exist.


Hehe - this is what I get for trying to throw this together at work.

Try this: i've included the list users at the top. I don't think userName needs to change.

Also - I think you may be misunderstanding the significance of key usernc.

Dataserver events have a handle, just like a listen has a handle - in this case, you're using 'usernc' for that. The data it contains is not the key of the notecard - its the key for the individual llGetNotecardLine request that was sent to dataserver.

Its done this way so that if you're making multipe dataserver queries in the same script, you can differentiate between them.

Anyway - here's your script, with a little more cleanup, and a lot of comments:

CODE
list users;
key usernc;
integer userncline;

default
{

dataserver(key id, string data)
{
if( id == usernc ) //if the dataserver query ID matches usernc (called with llGetNotecardLine)...
{
if( data != EOF ) //if we haven't reached the end of the notecard yet
{
users += [llToLower(data)]; //Add name found on this line to list data
lineNum++; // Prep to read the next line for the next loop
llWhisper(0,(string)users); //say the current user list
usernc = llGetNotecardLine("allowlist", lineNum); //loop back around again, and call another dataserver event
}
}
}


state_entry()
{
usernc = llGetNotecardLine("allowlist", userncline); //start the first dataserver event
}

touch_start(integer total_number) //if the list is empty or the owner touched it or the list says 'everyone' or the user is on the list...then do stuff!
{
string userName = llDetectedName(0); //set userName to the name of the person that clicked
if (llGetListLength(users) == 0 || llDetectedKey(0) == llGetOwner() || llListFindList(users, [llToLower(userName)]) != -1) //checking
{
//Do stuff with the door
}
else
{
llWhisper(0, "You cannot use this door."); //do this when the detected name fales to match the IF condition above
}
}
}
_____________________
------------------
The Shelter

The Shelter is a non-profit recreation center for new residents, and supporters of new residents. Our goal is to provide a positive & supportive social environment for those looking for one in our overwhelming world.