User talk:Mariasana Melodie
Jump to navigation
Jump to search
A brief bit of code I'd like comment about:
<lsl> //Copyright Mariasana Melodie 02-08-2011 //Simple script to prevent attachment/rezing of adult items in PG sims. //Put a copy in a no-mod poseball that is required for it to work, or root prim if entire item is no-mod. //Free to use, but give credit. (And for sanity sake, make the version IN the item no mod!)
default {
on_rez(integer start_param)
{
string maturity = llRequestSimulatorData (llGetRegionName(), 7);
if (maturity = "PG")
{
llOwnerSay("not here you don't.");
llDie();
}
}
attach(key id)
{
string maturity = llRequestSimulatorData (llGetRegionName(), 7);
if (maturity = "PG")
{
llOwnerSay("Try again in a Mature or Adult Region");
llDetachFromAvatar();
}
}
} </lsl>
--Mariasana Melodie 15:19, 8 February 2011 (PST)Mariasana Melodie
- Hi, you will need a dataserver event to capture and use the llRequestSimulatorData return values. Here are some changes to make it run, with a few notes to explain LSL's red tape. --Cerise Sorbet 17:10, 8 February 2011 (PST)
<lsl> key gLastQuery; // to make sure the dataserver response is fresh, and not for another script
default {
on_rez(integer start_param)
{
gLastQuery = llRequestSimulatorData (llGetRegionName(), DATA_SIM_RATING);
}
attach(key id)
{
if (id) // no use in checking on detach
{
gLastQuery = llRequestSimulatorData (llGetRegionName(), DATA_SIM_RATING);
}
}
changed (integer change)
{
if (change & CHANGED_REGION) // cover moving avatars and objects too
{
gLastQuery = llRequestSimulatorData (llGetRegionName(), DATA_SIM_RATING);
}
}
dataserver(key query, string data)
{
if (query != gLastQuery) return; // stale request, or not for this script
if (data == "PG")
{
if (llGetAttached())
{
llOwnerSay("Try again in a Mature or Adult Region");
llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); // need permission to detach
}
else
{
llOwnerSay("not here you don't.");
llDie(); // dangerous for no copy objects!
}
}
}
run_time_permissions(integer perms)
{
if (perms & PERMISSION_ATTACH)
{
llDetachFromAvatar();
}
}
} </lsl>
Thanks, Cerise Sorbet! It is, yes, a touch dangerous on no copy. Nice to get the feed back so quickly! Mariasana Melodie 01:22, 9 February 2011 (PST)Mariasana Melodie