Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Trouble with adding values to a list.

Felix Teriatzi
Registered User
Join date: 8 Jun 2009
Posts: 8
09-07-2009 17:11
I'm trying to create a microphone that relays messages from whitelisted avatars only. This is what I want the end product to be like, so I'll give an example.

'Bob Doe' is already authorized to use the microphone. When he talks, the microphone relays the message to the speakers.

'Jane Doe' is not authorized. When she talks, the microphone will not relay the message. She then uses the built-in authorization system to become whitelisted. She talks and the microphone relays the message.

So, here's my problem. I keep the whitelisted users in keys, so objects with the same name can't interfere, but I've hit a snag; the list doesn't seem to be able to update.

-

list microphone_whitelist = [];
string whitelist_search;
vector white = <1.0,1.0,1.0>;

default
{
state_entry()
{
llSetText("Microphone", <1.0,1.0,1.0>, 1.0);
llListen(0, "", NULL_KEY, "";);
}

listen(integer channel, string name, key id, string message)
{
whitelist_search = id;
integer whitelist_validate = llListFindList(microphone_whitelist, [whitelist_search]);
if (whitelist_validate == -1)
{
llOwnerSay("Unwhitelisted Avatar/Object is trying to use microphone";);
}
else
{
llRegionSay(100, ";("+name+";) "+message);
}
}

link_message(integer sender_num, integer num, string str, key id)
{
//For recording purposes, get name of person trying to authorize
string SendIDName = llKey2Name(id);
whitelist_search = id;
integer whitelist_validate = llListFindList(microphone_whitelist, [whitelist_search]);
if (whitelist_validate == -1)
{
//Code if unauthorized
llOwnerSay(SendIDName+" has been authorized to use the microphone.";);
llInstantMessage(id, "You have been authorized to use the microphone.";);
microphone_whitelist += microphone_whitelist + [id];
}
else
{
//Code if authorized
llOwnerSay(SendIDName+" is already authorized to use the microphone.";);
llInstantMessage(id, "You are already authorized to use the microphone.";);
}
}
}

-

In the command 'microphone_whitelist += microphone_whitelist + [id];', it does not update the list. If 'Jane Doe' were to get the 'Successful authorization' message, she would still be treated as an unwhitelisted agent.

Any ideas on how to get the list to successfully update? I appreciate any help.

(For the ID in link_message, the other script inside the microphone sends the proper ID- I can get the right name out of that.)
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
09-07-2009 17:45
Try this:

microphone_whitelist = microphone_whitelist + [id];

Getting rid of the "+=" and use "=" instead in that format.

:-)
Felix Teriatzi
Registered User
Join date: 8 Jun 2009
Posts: 8
09-07-2009 19:07
EDIT: Okay, I found this out after debugging with that code.

It's storing a KEY, but the validation is looking for a STRING.

Actually, this post is kind of a placeholder. >_>

EDIT EDIT: I got it working... I had to store the key as a string instead of... a key.
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
09-07-2009 19:42
From: Felix Teriatzi
EDIT: Okay, I found this out after debugging with that code.

It's storing a KEY, but the validation is looking for a STRING.

Actually, this post is kind of a placeholder. >_>

EDIT EDIT: I got it working... I had to store the key as a string instead of... a key.

it's because of this line at the top

string whitelist_search;

should work as a key if you use

key whitelist_search;

and in that case, i don't think you need it at all, it looks like in the script the only place you're using it is in the listen and link message event after retreiving it from the id fields. so really you could just search for id

integer whitelist_validate = llListFindList(microphone_whitelist, [id]);
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Felix Teriatzi
Registered User
Join date: 8 Jun 2009
Posts: 8
09-09-2009 09:03
Thanks, Ruthven. I finished the script recently exactly how I intended it.