Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: Menu/voice driven security device

Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
09-27-2008 13:37
Back when I was learning to script I used to pick a function and then just play with it in world to learn how to use it. One day I decided I was going to learn how to use menus and States. So I logged into the wiki on my laptop then logged into SL on my desktop. I opened a new script and eight hours later I had a fully functional menu/voice driven security script. Since I just whipped it out ad hoc, it's a little rough and needs some polishing, but it works fine as is.

It's been sitting in my inventory for two years now, totally unused. I've played with the idea of selling a security device in SL, but just never did.

In light of a thread about Socialism over on SLUniverse, I've decided to release it to the wild. Here it is, totally free for anyone who wants to use/hack it.

My name is Vares Solvang, and I'm a Socialist.

CODE
//Ejection script written by Vares Solvang September 18, 2006  
//This script is released for free use by anyone. Feel free to hack it, modify it, change it - whatever. It's yours to do
// with as you will.


integer ban = FALSE; // toggle for automatic banning of ejected person
integer doyou; // listen function for sub menus
key ejectem; // key of person to be ejected
string person; // person to be ejected
list alloweduserlist = []; // allowed users
integer CHANNEL = 4283; // dialog channel
list MENU_MAIN = ["ChangeUser", "List users", "Appearance", "Ban Only"]; // the main menu
list persontoeject = []; // used to parse eject command
key toucher; // key of person that touch started the menu
key user; // key of person using voice command ejection


default
{
on_rez(integer whatever)
{
llResetScript();
}
state_entry()
{
llListen(1000,"","","");
}
touch_start(integer total_number)
{
toucher = (llDetectedKey(0));
if (llListFindList(alloweduserlist, [llDetectedName(0)]) >=0 | toucher == llGetOwner())
llDialog(toucher, "What would you like to do?", MENU_MAIN, CHANNEL); // present dialog on click
llListen(CHANNEL,"","","");
}

listen(integer channel, string name, key id, string message)
{
user = id;
if (llGetSubString(message,0,4) == llToLower("eject") && id == llGetOwner() || llListFindList(alloweduserlist, [name]) >=0 && llGetSubString(message,0,4) == llToLower("eject")) // Starts scan for person to eject if speaker is authorized
{
list persontoeject = llParseString2List (message,["eject "],[]);
person = llDumpList2String(persontoeject,"");
llSensor(person,"",AGENT,96,PI);
}
else if (message == "ChangeUser")
{
state addremoveuser;
}
else if (message == "List users")
{
state listusers;
}
else if (message == "Appearance")
{
state appearance;
}
else if (message == "Ban Only")
{
state banonly;
}

}
sensor(integer total_number) // Ejection sequence
{
ejectem = llDetectedKey(0);
if (llOverMyLand(ejectem))
{
llSay(0,"Ejecting "+person+" now");
llEjectFromLand(ejectem);
state autoban;
}
else llSay(0,"I can not eject "+person+" because they are not on your land");
}
no_sensor()
{
llSay(0,person+" is not here");
}

}

state autoban // Menu to toggle automatic banning of ejected person on and off
{

state_entry()
{

list Auto_ban = ["Yes", "No"];
llListen(CHANNEL,"","","");
llSetTimerEvent(30);
llDialog(user, person+"Has been ejected, do you want to add "+person+" to the ban list?", Auto_ban, CHANNEL); // launch menu
}
listen(integer channel, string name, key id, string message)
{
if (message == "Yes" )
{
llAddToLandBanList(ejectem, 0);
llInstantMessage(user,person+" has been added to the ban list");
state default;
}
else if (message == "No" )
{
llInstantMessage(user,person+" has NOT been added to the ban list.");
state default;
}

}
timer()
{
state menureset;
}

}

state addremoveuser // Add and remove authorized users
{
state_entry()
{

list addremove = ["Add User", "RemoveUser"];
llListen(CHANNEL,"","","");
llSetTimerEvent(15);
llDialog(user, "Would you like to add an authorized user or remove one?", addremove, CHANNEL); // launch menu
}
listen(integer channel, string name, key id, string message)
{
if (message == "Add User")
{
state add;
}
else if (message == "RemoveUser")
{
state remove;
}
}
timer()
{
state menureset;
}

}
state appearance // change texture of ejector
{
state_entry()
{

list apperance = ["Visible", "Invisible"];
llListen(CHANNEL,"","","");
llSetTimerEvent(30);
llDialog(user, "Would you like your ejector to be visible or invisible?", apperance, CHANNEL); // launch menu
}
listen(integer channel, string name, key id, string message)
{
if (message == "Visible")
{
llSetAlpha(1.0, ALL_SIDES); // set entire prim 100% visible.
state default;
}
else if (message == "Invisible")
{
llSetAlpha(0.0, ALL_SIDES); // set entire prim 100% invisible.
state default;
}
}
timer()
{
state menureset;
}

}

state add // add authorized user
{
state_entry()
{
llListen(0,"","","");
llSetTimerEvent(30);
llInstantMessage(toucher,"Say the name of the person you want to authorize now, spelling and capitilization must match the persons name exactally.");

}
listen(integer channel, string name, key id, string message)
{
string addremove = message;
alloweduserlist = (alloweduserlist=[]) + alloweduserlist + addremove;
llInstantMessage(user, addremove+" has been added to the authorized user list");
//llSay(0, llDumpList2String(alloweduserlist," , "));
state default;
}
timer()
{
state menureset;
}
}
state remove // remove authorized user
{
state_entry()
{
llListen(0,"","","");
llSetTimerEvent(30);
llInstantMessage(toucher,"Say the name of the person you want to remove now, spelling and capitilization must match the persons name exactally.");


}
listen(integer channel, string name, key id, string message)
{
string addremove = message;
integer index = llListFindList( alloweduserlist, [addremove] );
if ( index = !1 )
{
llInstantMessage(user, addremove+" is not an authorized user.");
state default;
}
else
{
alloweduserlist = llDeleteSubList(alloweduserlist,index,index);
llInstantMessage(user, addremove+" has been removed to the authorized user list");
state default;
}
}
timer()
{
state menureset;
}

}
state listusers // IM's list of authorized users to toucher
{
state_entry()
{
integer l = llGetListLength(alloweduserlist);
if (l == 0)
{
llInstantMessage(user,"You are the only authorized user at this time.");
state default;
}
else
{
llInstantMessage(user, "Authorized users are "+llDumpList2String(alloweduserlist,", "));
state default;
}
}
}
state menureset
{
state_entry()
{
llInstantMessage(toucher, "Time has expired to respond, no action taken.");
state default;
}
}

state banonly // ban someone from your parcel
{
state_entry()
{
llListen(0,"","","");
llSetTimerEvent(30);
llInstantMessage(toucher,"Say the name of the person you want to ban now, spelling and capitilization must match the persons name exactally.");

}
listen(integer channel, string name, key id, string message)
{

{
llAddToLandBanList(message, 0);
llInstantMessage(toucher,message+" has been added to the ban list");
state default;
}

}
timer()
{
llInstantMessage(user," Timer has expired, no one has been added to the ban list.");
state menureset;
}
}


Notecard with basic instructions for use:

From: someone
To eject someone say: /1000 eject "person's name"

For example: /1000 eject Philip Linden

The person's name must be exact. Spelling and caPiTaliZatiOn MUST match.

The ejector has a 96m range, however it will only eject people on land that YOU own. The owner of the Ejector MUST be the owner of the land. You can use it with group land, but it must be deeded to the group in order to work.

Touch Ejector for menu options, most of which are self-explanitory. There is a time out on all of the menu options to reduce lag (we don't want it listening forever for a response that will never come), so if you get a "The Ejector 3.5: Time has expired to respond, no action taken." message, simply touch the menu option again to start over.

A number of the menu options will ask you to say the name of a person in open chat. Simply say the person's full name and nothing else. It will be listeing and will assume that the next thing you say is the person's name. Whenever it asks for a name, spelling and capitalization MUST match exactly.

You can click the Apperance button to change the Ejector to invisible mode. Even though it's invisible, you will still be able to touch it and get the menu. This is useful to keep others from playing with it, but since you know right where it is you can touch it any time you like, even if you can't see it.

You can add a custom "Ejection Message" if like. This is a message that will be sent as an IM to the person being ejected. It can be any message you like (or no message at all). The default is to NOT send a message when a person is ejected.
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Library bump
10-09-2008 07:42
:)
_____________________
i've got nothing. ;)
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
10-12-2008 12:26
I've placed a freebie version out at the Free Bazar in Stillman if you don't want to mess with making one yourself

Everything in it is full perms including the texture of a guy ejecting from a jet that I was going to use on the version I thought about selling. :)

http://slurl.com/secondlife/Stillman/164/95/25
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-12-2008 12:54
i haven't tried it yet. from what it looks like, it only ejects someone if you tell it to right? not an auto eject if they're not on the list, like a security orb?
_____________________
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
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
10-12-2008 13:16
From: Ruthven Willenov
i haven't tried it yet. from what it looks like, it only ejects someone if you tell it to right? not an auto eject if they're not on the list, like a security orb?


Exactly. It's biggest use would be for group owned land, such as a club. That way you can give event managers/hosts the ability to eject/ban trouble makers without having to muck about with group settings and such.

I just had a thought about a nice addition that would be pretty easy to do. It would be cool to put a timer option into this so you can set how long the person will have eject/ban privileges, after the time expires it would automatically remove that person from the authorized user list. So that way, if it's a two hour event you give the person auth for three hours (just in case the event goes over) and then after the event is done they are removed from the auth list automatically.

If I get to feeling industrious I will add one, but if someone else wants to add one and post it, that would be cool too.