Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Adding Access-Control to llDialog?

Eristic Strangelove
Registered User
Join date: 16 Nov 2005
Posts: 39
09-26-2008 14:27
So I have a super-simple pair of scripts for setting the opacity of windows using link_message and I wanted to add the option to let the Owner limit access to the controls by setting either PUBLIC, GROUP or OWNER access to the menu.

I thought I understood the theory, show the 'Set Access' sub-menu to the owner-only and then, depending on their choice, allow or disallow access to the main-menu to other users. I have another script which contains this feature and I thought it would be easy enough to merge the two scripts together. It isn't. At least not for me, I'm tying my script into knots.

Can anyone please advise on the simplest method to implement this controlled access - or point me to a simpler example I could merge with my existing script?

Thnx!

CONTROLLER:

CODE

integer menu_handler;
integer menu_channel;

menu(key user,string title,list buttons)
{
menu_channel = (integer)(llFrand(99999.0) * -1);
menu_handler = llListen(menu_channel,"","","");
llDialog(user,title,buttons,menu_channel);
llSetTimerEvent(5.0);
}

default
{state_entry()
{ llSetTouchText("windows");
}
touch_start(integer t)
{
menu(llDetectedKey(0),"Set the opacity for your windows...", ["closed","mid","open"]);
}
timer()
{
llSetTimerEvent(0.0);
llListenRemove(menu_handler);
}
listen(integer channel,string name,key id,string message)
{
if(message == "closed")
{
llMessageLinked(LINK_ALL_OTHERS, 0, "closed", "");
}
else if(message == "mid")
{
llMessageLinked(LINK_ALL_OTHERS, 0, "mid", "");
}
else if(message == "open")
{
llMessageLinked(LINK_ALL_OTHERS, 0, "open", "");

}
}
}


WINDOW SCRIPT:

CODE

default
{
link_message(integer sender_num, integer num, string message, key id)
{
if ( message == "closed" )
{
llSetAlpha(1.0, ALL_SIDES);
}
else if ( message == "mid" )
{
llSetAlpha(0.5, ALL_SIDES);
}
else if ( message == "open" )
{
llSetAlpha(0.0, ALL_SIDES);
}
}
}
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
09-26-2008 19:36
I already scripted such an access level thingy... Let's see what I remember...

key Owner;
integer AccessLevel = 2; // Set to owner only first.

key Avatar;
integer Handle;
list Access = ["Anybody", "Group", "Owner"];
list Opacity = ["Open", "Mid", "Closed"];

integer uuAuthorization(key av)
{
return llSameGroup(av) + 2 * (av == Owner); // 0:Anybody 1:Group 2:Owner
}

default
{
state_entry()
{
Owner = llGetOwner();
}

touch_start(integer total)
{
Avatar = llDetectedKey(0);
if (uuAuthorization(Avatar) < AccessLevel)
{
return; // Forbidden
}
list buttons = Opacity;
if (Avatar == Owner)
{
buttons += "Access"; // Mono style (No hack needed)
}
Handle = llListen(-9999, "", Avatar, "";);
llSetTimerEvent(60.0); // Time out
llDialog(Avatar, "Set the opacity of the windows...", buttons, -9999);
}

timer()
{
llSetTimerEvent(0.0);
llListenRemove(Handle);
llInstantMessage(Avatar, "Time out! The dialog is disabled.";);
}

listen(integer channel, string name, key id, string msg)
{
llSetTimerEvent(0.0);
llListenRemove(Handle);
if (button == "Access";)
{
Avatar = Owner
Handle = llListen(-9999, "", Avatar, "";);
llSetTimerEvent(60.0); // Time out
llDialog(Avatar, "Set access level...", Access, -9999);
return; // Quick exit
}
integer i = llListFindList(Access, [msg]);
if (i != -1)
{
AccessLevel = i; // 0:Anybody 1:Group 2:Owner
return; // Quick exit
}
i = llListFindList(Opacity, [msg]);
if (i != -1) // Should never fail...
{
llMessageLinked(LINK_ALL_OTHERS, i, "", "";);
}
}
}

WINDOW SCRIPT:

default
{
link_message(integer sender, integer opacity, string msg, key id)
{
if ( (opacity >= 0) && (opacity <= 2) ) // To be on the safe side...
{
llSetAlpha(0.5 * (float)opacity, ALL_SIDES);
}
}
}

Not tested but it should work... minus the eventual typos.
Eristic Strangelove
Registered User
Join date: 16 Nov 2005
Posts: 39
09-27-2008 07:08
Thanks for the help Kaluura. I get a syntax error in the control script, around line 52 but I can't see exactly where since the RC client has decided to hide the I-bar in the script window - that's in-between random crashes! :-) I'll reinstall the current release client and check again...

Your way of implementing the alpha-setting commands is probably much smarter than my basic efforts but it's maybe too clever for me. I need to be able to do more than just switch alpha settings and it's easier (for me) to implement it all with discrete commands. I'm pretty script-dumb but I usually get there in the end...

Appreciate the help!