Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llDialog and Variable Permissions: Help Needed

Raedel Flatley
Registered User
Join date: 16 Feb 2008
Posts: 4
09-20-2008 14:36
Hi all,
I've been working on this script and everything in it works just fine.. execpt setting the permissions. I'm trying to set the permission levels to Owner Only, Same Group, or Anyone with a polite message if you do not meet the current permission level via one of the dialog menus.

I just can't seem to get the permissions to change.. Currently if anyone clicks the object they get the correct menu but the permission settings seem to be ignored. This represents my first attempt at setting permissions via a menu so I KNOW I've bolloxed it up somewhere, but even with the help of the wiki, this form and the library I'm still not able to sort it out.

If someone could take a look and let me know just where and why I've gone wrong I would appreciate it. If you want to post a bit of corrected code I wouldn't mind that either :)

Here's the script as it stands:

CODE



//GLOBALS
key AGENTs;
key OBJECTS_OWNER;
integer GROUP;
integer INGROUP = FALSE;
integer PUBLIC = FALSE;
integer OWNER = FALSE;


//CHANNELS
integer CHANNEL = -395751;
integer CHANNEL_COLOR = -395752;
integer CHANNEL_POOF = -395753;
integer CHANNEL_FOG = -395754;
integer CHANNEL_PERM = -395755;

//LISTENERS
integer cLISTENER;
integer LISTENERc;
integer LISTENERp;
integer LISTENERf;
integer pLISTENER;

//LISTS
list MENU_MAIN = [ ];
list MENU_COLOR = ["Red", "Blue","Main", "Green", "Gold", "Purple"];
list MENU_POOF = ["Music", "Hearts", "Smiley", "Main"];
list MENU_FOG = ["Green", "White", "Main", "Purple", "Red", "Blue"];
list MENU_PERM = ["Owner", "Group", "Public", "Main"];

//FUNCTIONS
Mmenu()
{
llDialog(AGENTs,"Dance Floor Controller Mk2\nChoose activity", MENU_MAIN, CHANNEL);
}

//SCRIPT
default
{
on_rez(integer start_param)
{
llResetScript();
}

touch_start (integer total_number)
{
OBJECTS_OWNER = llGetOwner();
AGENTs = llDetectedKey(0);
GROUP = llDetectedGroup(0);

if (AGENTs == OBJECTS_OWNER)
{
MENU_MAIN =
[
"Fog Color",
"Set Particles",
"Pattern",
"Fog Off",
"Particles Off",
"Permissions",
"Fog On",
"Particles On",
"Bright"
];

Mmenu();
cLISTENER = llListen(CHANNEL,"",NULL_KEY,"");
llSetTimerEvent(30);
return;
}

else if (INGROUP == GROUP)
{
MENU_MAIN =
[
"Fog Color",
"Set Particles",
"Pattern",
"Fog Off",
"Particles Off",
"Fog On",
"Particles On",
"Bright"
];

Mmenu();
cLISTENER = llListen(CHANNEL,"",NULL_KEY,"");
llSetTimerEvent(30);
return;
}

else if (PUBLIC == TRUE)
{
MENU_MAIN =
[
"Fog Color",
"Set Particles",
"Pattern",
"Fog Off",
"Particles Off",
"Fog On",
"Particles On",
"Bright"
];

llDialog(AGENTs,"Dance Floor Controller Mk2\nChoose activity", MENU_MAIN, CHANNEL);
cLISTENER = llListen(CHANNEL,"",NULL_KEY,"");
llSetTimerEvent(30);
}

else
{
llInstantMessage(llDetectedKey(0),"You do not have permission to change the settings on this item");
llListenRemove(cLISTENER);
}
}

listen(integer channel, string name, key id, string message)
{
if (channel==CHANNEL)
{
if(llToLower(message)=="pattern")
{
llDialog(AGENTs,"Dance Floor Controller Mk2\nChoose Floor Pattern", MENU_COLOR, CHANNEL_COLOR);
LISTENERc = llListen(CHANNEL_COLOR,"",NULL_KEY,"");
}
else if (llToLower(message)=="fog color")
{
llDialog(AGENTs,"Dance Floor Controller Mk2\nChoose Fog Color", MENU_FOG, CHANNEL_FOG);
LISTENERf = llListen(CHANNEL_FOG,"",NULL_KEY,"");
}
else if (llToLower(message)=="set particles")
{
llDialog(AGENTs,"Dance Floor Controller Mk2\nChoose Particles", MENU_POOF, CHANNEL_POOF);
LISTENERp = llListen(CHANNEL_POOF,"",NULL_KEY,"");
}
else if (llToLower(message)=="main")
{
Mmenu();
}
else if (llToLower(message)=="fog on")
{
llSay(CHANNEL_FOG, "On");
Mmenu();
}
else if (llToLower(message)=="fog off")
{
llSay(CHANNEL_FOG, "Off");
Mmenu();
}
else if (llToLower(message)=="particles on")
{
llSay(CHANNEL_POOF, "On");
Mmenu();
}
else if (llToLower(message)=="particles off")
{
llSay(CHANNEL_POOF, "Off");
Mmenu();
}
else if (llToLower(message)=="bright")
{
llSay(CHANNEL_COLOR, "bright");
Mmenu();
}
else if (llToLower(message)=="permissions")
{
llDialog(AGENTs,"Dance Floor Controller Mk2\nSet Permissions", MENU_PERM, CHANNEL_PERM);
pLISTENER = llListen(CHANNEL_PERM,"",NULL_KEY,"");
}
}
if(channel==CHANNEL_COLOR)
{
if (llToLower(message)=="main")
{
Mmenu();
}
else
{
Mmenu();
}
}
if(channel==CHANNEL_POOF)
{
if (llToLower(message)=="main")
{
Mmenu();
}
else
{
Mmenu();
}
}
if (channel==CHANNEL_FOG)
{
if (llToLower(message)=="main")
{
Mmenu();
}
else
{
Mmenu();
}
}
if (channel==CHANNEL_PERM)
{
if (llToLower(message)=="owner")
{
INGROUP == FALSE;
PUBLIC == FALSE;
llOwnerSay("Permission set to Owner Only");
Mmenu();
}

if(llToLower(message)=="group")
{
INGROUP == TRUE;
PUBLIC == FALSE;
llOwnerSay("Permission set to Group");
return;
}

if(llToLower(message)=="public")
{
INGROUP == FALSE;
PUBLIC == TRUE;
llOwnerSay("Permission set to Public");
return;
}
}
}


timer()
{
llListenRemove(LISTENERc);
llListenRemove(LISTENERf);
llListenRemove(LISTENERp);
llSetTimerEvent(0);
}

}


Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
09-20-2008 16:01
By my reckoning (INGROUP == GROUP) means:

group is not allowed (INGROUP = FALSE) and I'm not in the group (GROUP = FALSE)

OR

group is allowed (INGROUP = TRUE) and I'm in the group (GROUP = TRUE)

...as you only want the second condition I would suggest:

(INGROUP == TRUE && GROUP == TRUE)

Extending the boolean logic you could avoid a lot of code repetition by doing the whole thing in the one condition:

if (AGENTs == OBJECTS_OWNER ||
(INGROUP == TRUE && GROUP == TRUE) ||
PUBLIC == TRUE)

(Note: && = AND, || = OR)
Raedel Flatley
Registered User
Join date: 16 Feb 2008
Posts: 4
09-20-2008 18:12
Thanks for the info on the Boolean's Pale.. I tried your fix and it's still not working. The owner only and the "polite message" are working now, but you still cannot sucessfully set group access or public access.

I'm going to keep trying so if you think of anything else please don't hesitate to suggest!
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
09-21-2008 01:37
heh... okay... I spotted something else:

INGROUP == FALSE;
PUBLIC == FALSE;

These (and other lines) should be:

INGROUP = FALSE;
PUBLIC = FALSE;

It's always a good idea to put in a few debug lines:

llOwnerSay("INGROUP " + (string)INGROUP);

...to check that the variables are really being set to their correct values.
Raedel Flatley
Registered User
Join date: 16 Feb 2008
Posts: 4
Fixed
09-21-2008 10:06
Well Pale.. YOU DID IT!!

The permission system is now working as intended. The problem was in using the " ==" in the wrong place.

When I ran the debug you suggested the variables were not being chnaged. Corrected to "=" and it all started working. Also kept your suggestion of consolodating the boolean logic. I did leave it split to what ammounts to "owner" and "group or public" as I wanted to present a different menu to the owner.

Another fix we both missed this time around but YOU commented on in another thread was getting the order of events right when calling the dialog menu. I was calling the menu THEN opening the listen channel... as you indicated that was just plain backwards and caused the menus to work only on the second time through.

So everthing now works great and you've earned a hearty "Thank You!!"
Thanks for helping a newbie scripter get a first "big" project off the ground.