Jump to content

The notecard-less "fast config" trick.


Kyrah Abattoir
 Share

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

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

Recommended Posts

Allright, this is old as hell, but fairly underused.

Rather than using a configuration notecard, which is slow and requires asynchronous parsing, there is a trick you can use:

  • Rather than using notecard lines, you use the inventory directly.
  • Instead of looking for notecard lines, you read the names of the inventory items and use that as your lines.

You can quickly iterate through llGetInventoryName(INVENTORY_NOTECARD, i) and fetch the name of every notecard in inventory.

Then it's just a matter of coming up with a configuration format, such as "key=value" (example: "operation_mode=owner").

As an added bonus, you can use the card description and content as a help file for this specific configuration entry.

 

But it doesn't stop there! For configuration options that are essentially "flags" (on/off or other values the system expects), you don't even necessarily have to "load" the configuration, since reading it is pretty much instant:

if( llGetInventoryType("operation_mode=owner") == INVENTORY_NOTECARD) will give you instantly whether the flag is set or not.

 

The object inventory itself can potentially be seen as a quick access "rom", so long as you know in advance what you are looking for, or that you are willing to iterate through every entry of a given inventory object type.

It is obviously not limited to notecards, in some items i use texture names for each entry.

  • Like 5
  • Thanks 3
Link to comment
Share on other sites

llGetPrimitiveParams also has some nifty ways of doing this too.  Colors can be used to store, retrieve and update information (switch_1 = color.x * 255) and then translated into binary information (3 color channels * 8 switches) for a total of 24 simple flags preferences per face (i.e "group/owner only", "local chat/silent", etc).

string Color2Bin(vector redValue)
{
    integer i;
    string buffer = "00000000";
    integer storeRed = (integer)(redValue.x*255);
    string binary;
    do
        binary = (string) (storeRed & 1) + binary;
    while (storeRed /= 2);
    i = llStringLength(binary);
    if (i < 8) binary = llDeleteSubString(buffer, -i, -1) + binary;
    return binary;
}

Colors can also be used to store integers.  And if the prim has no restrictions on permissions (have the user rez their own storage), UUID information (like avatar keys) can be stored and retrieved in a reset-proof format as texture information.

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

You are about to reply to a thread that has been inactive for 1453 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...