Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Two part question: Note Card Settings and If-else in listen

Artemis Cain
Take it or Leave it
Join date: 11 Apr 2005
Posts: 116
06-05-2006 08:19
Checked out the wiki and I believe I know how I should go about this, but I am still not too sure about it.

basically, what I am doing is setting an object to listen

CODE
 
default

state_entry()
{
llListen(0, "", llGetOwner, "command");
}

listen(integer chan, string name, key id, string message)

{

if (id !=llGetOwner) // this is where I want to add some other qualifiers, such as
// the other authorized users. Not sure how to do it though :/

{
llSay(0, "I shall not listen to you!");
return;
}

else

{
llSay(0, "What is thy bidding?"); // this is just in here for example from the top of my
// head. but this is where it would do whatever it
// needs to do when the command is spoken by
// either the owner or authorized users.

}

}


This is my first question.

I want to allow the owner to set other users via a notecard
I am guessing that I would use a "llCSV2List(my_notecard)" to create a list of authorized
users, of course after setting the script to read the notecard.
Am I correct in assumin this?

Second question is:

should I just have the script pull each name out of the list
ie
CODE

HOST1 = llList2String(list, 0);
HOST2 = llList2String(list, 1);
// and so on?


I hope this makes sense... writing it out actually helped me to understand what I am saying a little better!

Thanks!

- Artemis
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
06-05-2006 08:54
From: Artemis Cain
Second question is:

should I just have the script pull each name out of the list

It's probably easier to just build a list of keys (UUIDs) of authorized users, from the notecard or by any other means... then during your safety check just scan the list for presence of key of person who triggered the listen event:
CODE

list authorized_keys;

listen( integer Channel, string Name, key Id, string Message ) {

if( llListFindList( authorized_keys, [Id] ) == -1 ) return; // this user is not on the list

// carry on with regular stuff here
}
Draco18s Majestic
Registered User
Join date: 19 Sep 2005
Posts: 2,744
06-05-2006 08:56
First off, llGetOwner is a function.
if(id != llGetOwner) fails. You need if(id != llGetOwner())
Artemis Cain
Take it or Leave it
Join date: 11 Apr 2005
Posts: 116
06-05-2006 09:41
From: Joannah Cramer
It's probably easier to just build a list of keys (UUIDs) of authorized users, from the notecard or by any other means... then during your safety check just scan the list for presence of key of person who triggered the listen event:
CODE

list authorized_keys;

listen( integer Channel, string Name, key Id, string Message ) {

if( llListFindList( authorized_keys, [Id] ) == -1 ) return; // this user is not on the list

// carry on with regular stuff here
}


this is where it gets fuzzy for me. I have never used a notecard system for this. will I be able to (if I have avatar names in the notecard) get their keys somehow, or will I have to just get a script to return the key of an avatar and then just have the end user copy and paste that in to the notecard?

as for the llGetOwner(), I wrote the code freehand as I was posting just to show an example, I apologize for my error however....
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
06-05-2006 10:12
you can actually use the names in the notecard if you wish. after you put the names in the notecard and put them in the list, use the same code as porvided except for [id], use [llKey2Name(id)].

This only works if the player is in the same sim, but I do not thing that is a problem for listening.
Artemis Cain
Take it or Leave it
Join date: 11 Apr 2005
Posts: 116
06-05-2006 10:17
From: Lazink Maeterlinck
you can actually use the names in the notecard if you wish. after you put the names in the notecard and put them in the list, use the same code as porvided except for [id], use [llKey2Name(id)].

This only works if the player is in the same sim, but I do not thing that is a problem for listening.

That is the first thing that came to mind for me, but I was thinking backwards, I was thinking I would have to get an llName2Key(if such a beast even existed)

thanks for the nudge in the right direction!
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
06-05-2006 12:00
From: Artemis Cain
will I be able to (if I have avatar names in the notecard) get their keys somehow, or will I have to just get a script to return the key of an avatar and then just have the end user copy and paste that in to the notecard?

It was mostly just personal preference to use keys, to be honest ^^ you can instead use either the key2name() call like already pointed out, or do comparison vs name of whatever triggered the event, rather than its key:
CODE

list authorized_names

listen( integer Channel, string Name, key Id, string Message ) {

if( llListFindList( authorized_names, [Name] ) == -1 ) return; // this user is not on the list

// carry on with regular stuff here
}