Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Access to dialog menus...?

Layton Destiny
Crackpot Inventor
Join date: 28 Feb 2008
Posts: 13
01-30-2010 12:36
Hello all,

I am having difficulty adding code to a script so that the agent using the script will be able to define(using the dialog menu) who has access to operate dialog menu and the scripted object.
I want the owner to have access only on rezzing the object, but then to be able to touch it and activate a dialog menu which will allow them to choose from the options "Open", "Group", or "Owner Only".
If anyone can help would be very grateful.
Thanks:)
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-30-2010 13:21
This almost certainly has typos in it, but it should give you the idea......

CODE

list OK2Use = [];
integer DiaListen;
integer SetAccess;
integer OwnerUse;
integer Access;
integer OwnerOK = FALSE;
default
{
state_entry()
{
if (OwnerOK) // If the owner has previously set access approvals
{
state run;
}
}

on_rez(integer flag)
{
if (OwnerOK) // If the owner has previously set access approvals.....
{
state run;
}
else
{
DiaListen = llListen(-25,"","","");
llDialog(llDetectedKey(0),"Type access keys in channel 35, one per chat line, then click the \"FINISHED\" button.", ["FINISHED"],-25);
SetAccess = llListen(35,"",llDetectedKey(0),"");
}
}

listen (integer channel, string name, key id, string msg)
{
if (channel == 35) // Establish access list
{
OK2Use += (key)msg;
}
else if (channel == -25) // Finalize access list
{
llSay(0, "Access list complete and recorded. Only the Owner can approve use now.");
OwnerUse = llListen(-4567, "","","");
llDialog(llGetOwner(),"Who should use this device?", ["Me Only", "Group", "Anyone"], -4567);
}
else if(channel == -4567) //Set access level
{
if (msg = "Me Only")
{
Access = 0;
OwnerOK = TRUE;
state run;
}
else if (msg = "Group")
{
Access = 1;
OwnerOK = TRUE;
state run;
}
Access = 2;
OwnerOK = TRUE;
state run;
}
}
}

state run
{
touch_start (integer num)
{
if (Access == 0 && llDetectedKey(0) != llGetOwner())
{
llSay(0,"Sorry. Only the owner is allowed to touch this device.");
state default;
}
else if(Access == 1 && -1 == llListFindList(OK2Use,[llDetectedKey(0)]))
{
llSay(0,"Sorry. Only group members are allowed to use this device.");
state default;
}
else
{
//Do approved stuff
state default;
}
}
}
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Layton Destiny
Crackpot Inventor
Join date: 28 Feb 2008
Posts: 13
Access to dialog menus...?
01-30-2010 13:37
Many thanks for that Roliq, just trying to work it into my script now:)
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-30-2010 13:51
OK, but note that I just had a brilliant insight :rolleyes: and updated the script I posted earlier. The one I posted before didn't meet your on_rez expectations.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Layton Destiny
Crackpot Inventor
Join date: 28 Feb 2008
Posts: 13
Access to dialog menus...?
01-30-2010 13:56
Yes, I just noticed that , thanks again:)
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-30-2010 14:05
Incidentally, my trial script has the owner build the access list by typing it one line at a time into channel 35. This approach has several drawbacks. The most obvious one is that there's no way to correct a typo or update the list once it's recorded, short of resetting the script and starting all over again. You could avoid some of those problems by building in an update routine, or you could type the approved keys directly into the global OK2Use list, or you could rewrite the front end of the script to read the access list in from a notecard instead. Personally, I'd prefer the notecard approach.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Layton Destiny
Crackpot Inventor
Join date: 28 Feb 2008
Posts: 13
Access to dialog menus...?
01-30-2010 14:17
Yes i understand that but i just want to be able to set to "Open", "Owner" or "Group". Don't really want to build a list of specific AVs, just set to three options.
Trying to avoid the notecard approach as I want the object to be no mod, and think i will need to leave mod rights open if i want the owner to be able to edit a notecard.
Thanks for posting anyways, what you have there should help i think:)
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-30-2010 14:24
That's cool. Just for completeness, I went back and corrected three or four typos that made the script fail to compile as written before. At least now you have a working script to dismember and rebuild. Good luck with it. :)

BTW, you can allow a notecard change without having to set the object to mod. Just use llAllowInventoryDrop.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Layton Destiny
Crackpot Inventor
Join date: 28 Feb 2008
Posts: 13
Access to dialog menus...?
01-30-2010 14:28
Ah ...nice tip about llAllowInventoryDrop...thanks for that...and yes much easier to have a working script to work from;)
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
01-30-2010 16:31
Here is a working sample of something I put together a long whiles ago but still use today.
Everyone is more than welcome to use it as they see fit!

CODE


// Only Owner Will Have Access to Dialog Menus Upon Rez
// Owner Can Then Set User Access to Group or All (everyone) or Not.

// Owner Only - Access to All Options
list MENU_MAIN = ["A", "B", "C", "D", "E", "F", "G", "Set User"];

// Group & All - Access to Limited Options
list MENU_SMAIN = ["A", "B", "C", "D", "E"];

// Access Options
list MENU_SETUSER = ["Group", "All", "...Back", "Owner"];

// Access Variables
key user;
integer group;
integer all;
string access;

//Random Comm
integer random_chan;
integer chan;

default
{
state_entry()
{
random_chan = 0;
llListenRemove(chan);
// User Access
group = FALSE;
all = FALSE;
access = " Owner";
//Random Comm Generation
do
{
random_chan = ((integer) llFrand(3) - 1) * ((integer) llFrand(2147483647));
}
while(random_chan == 0);
}

on_rez (integer start_param)
{
llResetScript();
}

touch_start(integer total_number)
{
user = llDetectedKey(0);
chan = llListen(random_chan, "", user,"");
if (user == llGetOwner())
llDialog(llGetOwner(), "
Select a Button!", MENU_MAIN, random_chan);
else if (group)
{
if (user != NULL_KEY)
{
if(llSameGroup(user))
llDialog(user, "
Select a Button!", MENU_SMAIN, random_chan);
}
}
else if (all)
{
if (user != NULL_KEY)
{
llDialog(user, "
Select a Button!", MENU_SMAIN, random_chan);
}
}
}

// Main Menu
listen(integer channel, string name, key id, string message)
{


//Sample Menu
{if (message == "A")
// Insert Function
{}
else if (message == "B")
// Insert Function
{}
else if (message == "C")
// Insert Function
{}
else if (message == "D")
// Insert Function
{}
else if (message == "E")
// Insert Function
{}
else if (message == "F")
// Insert Function
{}
else if (message == "G")
// Insert Function
{}
}

// Set User Menu
{if (message == "Set User")
llDialog(user, "
Select User Access.
User Access is Currently:" + access, MENU_SETUSER, random_chan);
else if (message == "Group")
{
group = TRUE;
all = FALSE;
access = " Group";
}
else if (message == "All")
{
group = FALSE;
all = TRUE;
access = " All";
}
else if (message == "Owner")
{
group = FALSE;
all = FALSE;
access = " Owner";
}

// Back Button Function

else if(message == "...Back")
{
if (user == llGetOwner())
{
llDialog(llGetOwner(), "
Select a Button!", MENU_MAIN, random_chan);
}
else if (group)
{
if (user != NULL_KEY)

{
if(llSameGroup(user))
llDialog(user, "
Select a Button!", MENU_SMAIN, random_chan);
}
}

else if (all)
{
if (user != NULL_KEY)
{
llDialog(user, "
Select a Button!", MENU_SMAIN, random_chan);
}
}
}
}
}
}

_____________________
There's no place like home... click
Layton Destiny
Crackpot Inventor
Join date: 28 Feb 2008
Posts: 13
Access to dialog menus...?
01-31-2010 07:03
Thanks muchly for that , Zena:) I am certain that I can figure it out from here, just need to get this code to compile into my existing script now;)
This is all helping to improve my general understanding of this kind of script too (let's face it, any understanding, compared to zero, is an improvement lol).