JasXSL / JasX-HUD

JasX HUD v0.3 and beyond in Second Life
MIT License
9 stars 1 forks source link

RFC for tagging system #21

Closed JasXSL closed 8 months ago

JasXSL commented 1 year ago

So I was recently made aware that you can scan avatar attachments. Perhaps we could use a tagging system for descriptions. The purpose is to let code scan the avatar and read metadata about what they look like. Ex: If the avatar has a tail, fur, scale etc. This will make NPCs more reactive to what you're wearing and what your body looks like.

Tags are set in non-HUD attachment descriptions.

Description Syntax

TAG$tag_a$tag_b$tag_c... This allows for compatibility with the XOBJ tagging syntax of Task$var$$task$var...

You may add a prefix marked by starting a tag with !: TAG$!tail$long$furry$fluffy would be the same as TAG$tail_long$tail_furry$tail_fluffy. The purpose is to allow slots with a lot of tags (like body) to save space in the description. You can end or change the prefix by putting another ! in. Such as TAG$!tail$long$furry$!skin$fur$red$white$!$head_teeth

Tag syntax

Tags would use the format <slot>_<tag>, like body_fat, tail_long, or breasts_large. Tags must be lowercase and may only include a-z characters (and the _ separator). Tags can use multiple separators if you need multiple categories eyes_left_blind.

Tag library

There would be a preprocessor library with the most commonly used tags as standard tags. But users can create and search for their own tags at will. A standard library is there to allow both users and devs know what tags most people would use.

I'd love some comments on this before implementing any code.

JasXSL commented 8 months ago

Working a bit more on this. To make tags coherent, I suggest we sort the tags into the following categories:

Primary

These are tags that should be added first, because they describe things that most devs will have use for. These include genital flags, species, gender etc.

Recommended

These are tags that are recommended, but probably won't be used that much. Such as describing if your avatar has a tail, hair length etc etc.

Specific

Anything that probably won't be used outside of very specific circumstances.

We should also probably keep separate lists for adult tags and PG tags. There should probably also be a list of presumed defaults. Such as by default we'll assume that an avatar is a biped. And you have to explicitly state that your avatar is a quadruped to override it.

JasXSL commented 8 months ago

Example code to play around with

list sTagAv( key id, string prefix ){

    list l = llGetAttachedList(id);
    list out; integer i = (l != []);
    while( i-- )
        out += sTag(
            llList2String(llGetObjectDetails(llList2Key(l, i), (list)OBJECT_DESC), 0),
            prefix
        );
    return out;

}
list sTag( string desc, string prefix ){

    list spl = llParseString2List(desc, (list)"$$", []);
    integer i = spl != [];
    list out;
    while( i-- ){

        if( llGetSubString(llList2String(spl, i), 0, 3) == "TAG$" ){

            list sub = llParseString2List(
                llGetSubString(llList2String(spl, i), 4, -1),
                (list)"$", []
            );

            string pre;
            integer n;
            for(; n < (sub != []); ++n ){

                string val = llList2String(sub, n);
                if( llOrd(val, 0) == 0x21 ){

                    pre = llDeleteSubString(val, 0, 0);
                    val = "";

                }
                else if( pre )
                    val = pre+"_"+val;                

                if( 
                    llStringLength(val) && (
                        !llStringLength(prefix) ||
                        llGetSubString(val, 0, llStringLength(prefix)) == prefix+"_"
                    )
                )out += val;

            }

        }

    }
    return out;

}

default
{
    state_entry()
    {
        list out = sTagAv(llGetOwner(), "");
        llOwnerSay(llList2Json(JSON_ARRAY, out));
    }
}

Example body description: TAG$species_fox$!gen$vagina$breasts$!fur$orange$white$black

Expected output: ["species_fox","gen_vagina","gen_breasts","fur_orange","fur_white","fur_black"]

If you use sTagAv(llGetOwner(), "fur") you'd instead get: ["fur_orange","fur_white","fur_black"]

Kadah commented 8 months ago

I like the idea. Adoption would be key though.

You may add a tag start specifier marked by starting a tag with !: TA$!tail$long$furry$fluffy would be the same as TA$tail_long$tail_furry$tail_fluffy. The purpose is to allow slots with a lot of tags (like body) to save space in the description. You can end or change the prefix by putting another ! in. Such as TA$!tail$long$furry$!skin$fur$red$white$!$head_teeth

Using the term "prefix" would make this easier to understand.

JasXSL commented 8 months ago

Moved this to its own repo: https://github.com/JasXSL/sTag/