Jump to content

A way to have a hud Auto change your clothing....


FifthWarden
 Share

You are about to reply to a thread that has been inactive for 447 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Ok.. So the other day I had a thought come to me as i took my avatar between sims/parcels of different Ratings. I.E. Going from an adult sim, to a moderate.

Would there be a way to use a script to Automatically change my clothing to fit the rating of the sim?

I know it would likely require RLV, and setting up a folder in the #RLV folder with the outfit you want for that rating. I want it to be an automatic thing, like some of the Group changer huds, that change your active group tag to match the parcels group.

Does anyone have any idea of how I might go about this?

  • Like 1
Link to comment
Share on other sites

I haven't used RLV in ages, but this should work, or at least be a good starting point for something better.

key gQuery;

// Setup:
// [inventory_root]/#RLV/swapitems/adult/[itemshere]
// [inventory_root]/#RLV/swapitems/moderate/[itemshere]
// [inventory_root]/#RLV/swapitems/pg/[itemshere]

string gFolderAdult = "swapitems/adult";
string gFolderModerate = "swapitems/moderate";
string gFolderPg = "swapitems/pg";

getRating()
{
    gQuery = llRequestSimulatorData(llGetRegionName(), DATA_SIM_RATING);
}

default
{

    on_rez(integer Setting)
    {
        llResetScript();
    }

    state_entry()
    {
        getRating();
    }

    changed(integer change)
    {
        if (change & (CHANGED_OWNER | CHANGED_REGION | CHANGED_TELEPORT))
        {
            getRating();
        }
    }

    dataserver(key query_id, string data)
    {
        if (query_id == gQuery)
        {
            if (data == "ADULT")
            {
                llOwnerSay("@attachallover:" + gFolderAdult + "=force,detachall:" + gFolderModerate + "=force,detachall:" + gFolderPg + "=force");
            }
            else if (data == "MATURE")
            {
                llOwnerSay("@detachall:" + gFolderAdult + "=force,attachallover:" + gFolderModerate + "=force,detachall:" + gFolderPg + "=force");
            }
            else // PG or UNKNOWN
            {
                llOwnerSay("@detachall:" + gFolderAdult + "=force,detachall:" + gFolderModerate + "=force,attachallover:" + gFolderPg + "=force");
            }
        }
    }
    
}

 

Edited by panterapolnocy
  • Like 1
Link to comment
Share on other sites

5 hours ago, panterapolnocy said:
                llOwnerSay("@attach:swapitems/adult=force");
                llOwnerSay("@detach:swapitems/moderate=force");
                llOwnerSay("@detach:swapitems/pg=force");

Not especially relevant in this specific case, but multiple sequential RLV commands can be strung together with commas, for example:

llOwnerSay("@attach:swapitems/adult=force,detach:swapitems/moderate=force,detach:swapitems/pg=force");

Also, to avoid some possibly unexpected behavior related to attachment points, and recursively attach sub folders, 'attachallover' and 'detachallover' are probably preferable to attach and detach.

Given the susceptibility of rigged attachments to slow attach/detach times, it might make sense to consider the attach/detach order depending on what's in the folders and where you're landing (If you're going to a PG area, adding conservative clothes before removing revealing ones might make sense to avoid a few moments of nudity. OTOH, not-pg-safe attachments ought be removed as fast as possible)

Edited by Quistess Alpha
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Quistess Alpha said:

Not especially relevant in this specific case, but multiple sequential RLV commands can be strung together with commas

Thanks, I modified my original post to use this format. As I've mentioned, I may be a bit rusty in the area of RLV/RLVa. Not really using it much, even as a non-collar utility.

1 hour ago, Quistess Alpha said:

, 'attachallover' and 'detachallover'

I may be wrong on that (again!) but does such a thing as "detachallover" exist? I cannot see a definition for it in https://github.com/FirestormViewer/phoenix-firestorm/blob/dcfe6760e9dd645b7c8657b70fd343b8595dfd81/indra/newview/rlvhelper.cpp#L265

Link to comment
Share on other sites

5 hours ago, panterapolnocy said:

I may be wrong on that (again!) but does such a thing as "detachallover" exist? I cannot see a definition for it in https://github.com/FirestormViewer/phoenix-firestorm/blob/dcfe6760e9dd645b7c8657b70fd343b8595dfd81/indra/newview/rlvhelper.cpp#L265

I don't think there's any. And I did a *lot* of research on this, having to implement a standalone "Outfit System" for my group.

In my code I implemented it this way:

if (!llSubStringIndex(message, "@don|p=")) {
    string which = llDeleteSubString(message, 0, llSubStringIndex(message, "="));
    if (!~llListFindList($AvailOutfits, (list)which)) {
        SayToMaster("ERR:don|e=nofolder,p=" + which);
        return;
    }
    llOwnerSay("@detachall:" + BOS_OUTFITS + "/" + which + "/no=force");
    llSleep(2);
    llOwnerSay("@attachallover:" + BOS_OUTFITS + "/" + which + "/yes=force");
    llSleep(2);
    SayToMaster("OK:don|p=" + which);
    return;
}

So there's @attachallover but only @detachall

(Explanation: This bit of code detaches every link inside a folder BOS_OUTFITS/no , then attaches every link inside a folder BOS_OUTFITS/yes )

Edited by primerib1
  • Like 1
Link to comment
Share on other sites

5 hours ago, panterapolnocy said:

but does such a thing as "detachallover" exist?

No, pardon my accidental injection of similar names. and FWIW the documentation I use is on the wiki: LSL Protocol/RestrainedLoveAPI - Second Life Wiki  (and for relay reference) LSL Protocol/Restrained Love Relay/Specification - Second Life Wiki

  • Like 2
Link to comment
Share on other sites

22 minutes ago, FifthWarden said:

I appreciate All the information. I tried this and it works but sometimes it also removes other items including the item with the script in it.. This is a good working starting point.

Well you need to leave out the item from the folders that will be detached, then.

There is no need for the autochanger HUD to be automagically attached/detached; just keep it attached permanently / as long as you want it.

  • Like 1
Link to comment
Share on other sites

2 hours ago, FifthWarden said:

it also removes other items

If you don't use one of the 'over' RLV commands, it works like if you 'add' instead of 'wear' something from your inventory: things on the same attachment point can be pushed off.

If that's the issue, rename the folder to have a '+' at the front of it in the script and the actual folder, or use @attachover / @attachallover

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Ok.. so.. this started another thought.. As in a way to change clothes based on the Name of the sim or parcel.. Like I go to a club, i have it auto change to a outfit for the club, but if i go to a rp sim, it changes to my rp clothes.. been trying GetName and (llGetParcelDetails(), PARCEL_DETAILS_NAME); but it gives me ERROR : Function call mismatches type or number of arguements.

 

Link to comment
Share on other sites

There are general structural changes to the script to make it work with such functions (because they return values directly, without needing the dataserver step), so that may need other attention, but it's still branching based on matches with string values. So I'm guessing the problems arise in calling the functions. Maybe this would be a hint:


        // try more specific parcel name match first
        string parcelName = llList2String(llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME]), 0);
        if ("MacBoatface" == parcelName)
        {
            llOwnerSay("RLV magic to wear the MacBoatface outfit");
            return;
        }
        // else if other parcel name matches
        // fall back to region name match
        string regionName = llGetRegionName();
        if ("Kabuto" == regionName)
        {
            llOwnerSay("RLV magic to wear the Kabuto outfit");
        }
        // else if other region name matches
        else
        {
            llOwnerSay("Maybe call llRequestSimulatorData(regionName, DATA_SIM_RATING) like before and branch in dataserver");
        }

 

Link to comment
Share on other sites

  • 2 weeks later...
On 2/10/2023 at 10:53 PM, Qie Niangao said:
        // try more specific parcel name match first
        string parcelName = llList2String(llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME]), 0);

Fun trick: If the list contains exactly 1 item and the item is of type string, you can just typecast it to string.

string parcelName = (string)llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME]);
  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 447 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...