Tweenster/Auto Alpha: Difference between revisions

From CasperTech Wiki
Jump to navigation Jump to search
(Created page with "Auto Alpha is a system for creators to automatically set alphas on the Tweenster body when an item of clothing is worn. With Tweenster v3, Auto Alpha is really simple to use!...")
 
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 3: Line 3:
With Tweenster v3, Auto Alpha is really simple to use!
With Tweenster v3, Auto Alpha is really simple to use!


# First, under "Alpha Cuts" on the Tweenster HUD, click "Clear All".
<ol>
# Next, click the segments to set the alpha segments to suit your garment.
<li>First, under "Alpha Cuts" on the Tweenster HUD, click "Clear All".</li>
# On the Tweenster HUD, click "Options" and then choose "5" for "Output auto alpha code"
<li>Next, click the segments to set the alpha segments to suit your garment.</li>
# In a few seconds, you will see some output like this:
<li>On the Tweenster HUD, click "Options" and then choose "5" for "Output auto alpha code"</li>
<li>In a few seconds, you will see some output like this:


<pre>
<pre>
[06:40] >MM< Tweenster HUD v3: Your code is between the lines:
[06:40] >MM< Tweenster HUD v3: Your code is between the lines:
[06:40] >MM< Tweenster HUD v3: -------------------------------
[06:40] >MM< Tweenster HUD v3: -------------------------------
[06:40] >MM< Tweenster HUD v3: SendAlphas(1, 1610435638, 255, 0);
[06:40] >MM< Tweenster HUD v3: SendAlphas(1, 33377316, 255, 0);
[06:40] >MM< Tweenster HUD v3: SendAlphas(1, 256, 115, 140);
[06:40] >MM< Tweenster HUD v3: SendAlphas(1, 256, 115, 140);
[06:40] >MM< Tweenster HUD v3: SendAlphas(2, 32775, 255, 0);
[06:40] >MM< Tweenster HUD v3: SendAlphas(1, 33554432, 24, 231);
[06:40] >MM< Tweenster HUD v3: SendAlphas(2, 8, 126, 129);
[06:40] >MM< Tweenster HUD v3: SendAlphas(2, 16, 63, 192);
[06:40] >MM< Tweenster HUD v3: SendAlphas(2, 8192, 25, 230);
[06:40] >MM< Tweenster HUD v3: SendAlphas(2, 8192, 25, 230);
[06:40] >MM< Tweenster HUD v3: SendAlphas(2, 16384, 3, 252);
[06:40] >MM< Tweenster HUD v3: SendAlphas(2, 16384, 3, 252);
[06:40] >MM< Tweenster HUD v3: -------------------------------
[06:40] >MM< Tweenster HUD v3: -------------------------------
</pre>
</pre>
 
</li>
# Copy the part between the ---- lines, and remove the bit at the front, so it becomes:
<li>Copy the part between the ---- lines, and remove the bit at the front, so it becomes something like:


<pre>
<pre>
SendAlphas(1, 1610435638, 255, 0);
SendAlphas(1, 33377316, 255, 0);
SendAlphas(1, 256, 115, 140);
SendAlphas(1, 256, 115, 140);
SendAlphas(2, 32775, 255, 0);
SendAlphas(1, 33554432, 24, 231);
SendAlphas(2, 8, 126, 129);
SendAlphas(2, 16, 63, 192);
SendAlphas(2, 8192, 25, 230);
SendAlphas(2, 8192, 25, 230);
SendAlphas(2, 16384, 3, 252);
SendAlphas(2, 16384, 3, 252);
Line 34: Line 31:


(Please note that this is only an example, your output will be different).
(Please note that this is only an example, your output will be different).
 
</li>
# Next, paste these lines between the "// ------ PASTE CODE BELOW ------" and "// ------ PASTE CODE ABOVE ------" lines in the script, replacing what is there already.
<li>Next, paste these lines between the "// ------ PASTE CODE BELOW ------" and "// ------ PASTE CODE ABOVE ------" lines in the script (it's around line 32), replacing what is there already.</li>
# Hit save, and you're done! Just drop the script into your clothing. You may wish to set perms, but this is up to you.
<li>Hit save, and you're done! Just drop the script into your clothing. You may wish to set perms, but this is up to you.</li>
</ol>


== Script ==
== Script ==
Line 43: Line 41:
//
//
//
//
//      Tweenset Alpha Control API V3
//      Tweenster Alpha Control API V3
//
//
//      License: Creative Commons Attribution-ShareAlike 4.0 International
//      License: Creative Commons Attribution-ShareAlike 4.0 International
//
//
//      Copyright (2017) Meshmerized and CasperTech Ltd
//      Copyright (2018) Meshmerized and CasperTech Ltd
//
//
//
//
Line 62: Line 60:
//
//
//  Simply set the alphas you want on Tweenster. Then, on the HUD,
//  Simply set the alphas you want on Tweenster. Then, on the HUD,
//  go to OPTIONS and then 4 for "Output Auto Alpha Code".
//  go to OPTIONS and then 5 for "Output Auto Alpha Code".
//
//
//  Then, simply paste the code into the AutoAlpha function below
//  Then, simply paste the code into the AutoAlpha function below
Line 72: Line 70:
{
{
     // ------ PASTE CODE BELOW ------
     // ------ PASTE CODE BELOW ------
     PrepareAlphas(1, 33377316, 255, 0);
     SendAlphas(1, 33377316, 255, 0);
     PrepareAlphas(1, 256, 115, 140);
     SendAlphas(1, 256, 115, 140);
     PrepareAlphas(1, 33554432, 24, 231);
     SendAlphas(1, 33554432, 24, 231);
     PrepareAlphas(2, 8192, 25, 230);
     SendAlphas(2, 8192, 25, 230);
     PrepareAlphas(2, 16384, 3, 252);
     SendAlphas(2, 16384, 3, 252);
     // ------ PASTE CODE ABOVE ------
     // ------ PASTE CODE ABOVE ------
}   
}   
Line 97: Line 95:
string passCode = "";
string passCode = "";


PrepareAlphas(integer set, integer partMask, integer faceMask, integer alphaMask)
SendAlphas(integer set, integer partMask, integer faceMask, integer alphaMask)
{
{
     setCommands += [llDumpList2String([set, partMask, faceMask, alphaMask], "\n")];
     setCommands += [llDumpList2String([set, partMask, faceMask, alphaMask], "\n")];

Latest revision as of 13:54, 15 July 2018

Auto Alpha is a system for creators to automatically set alphas on the Tweenster body when an item of clothing is worn.

With Tweenster v3, Auto Alpha is really simple to use!

  1. First, under "Alpha Cuts" on the Tweenster HUD, click "Clear All".
  2. Next, click the segments to set the alpha segments to suit your garment.
  3. On the Tweenster HUD, click "Options" and then choose "5" for "Output auto alpha code"
  4. In a few seconds, you will see some output like this:
    [06:40] >MM< Tweenster HUD v3: Your code is between the lines:
    [06:40] >MM< Tweenster HUD v3: -------------------------------
    [06:40] >MM< Tweenster HUD v3: SendAlphas(1, 33377316, 255, 0);
    [06:40] >MM< Tweenster HUD v3: SendAlphas(1, 256, 115, 140);
    [06:40] >MM< Tweenster HUD v3: SendAlphas(1, 33554432, 24, 231);
    [06:40] >MM< Tweenster HUD v3: SendAlphas(2, 8192, 25, 230);
    [06:40] >MM< Tweenster HUD v3: SendAlphas(2, 16384, 3, 252);
    [06:40] >MM< Tweenster HUD v3: -------------------------------
    
  5. Copy the part between the ---- lines, and remove the bit at the front, so it becomes something like:
    SendAlphas(1, 33377316, 255, 0);
    SendAlphas(1, 256, 115, 140);
    SendAlphas(1, 33554432, 24, 231);
    SendAlphas(2, 8192, 25, 230);
    SendAlphas(2, 16384, 3, 252);
    

    (Please note that this is only an example, your output will be different).

  6. Next, paste these lines between the "// ------ PASTE CODE BELOW ------" and "// ------ PASTE CODE ABOVE ------" lines in the script (it's around line 32), replacing what is there already.
  7. Hit save, and you're done! Just drop the script into your clothing. You may wish to set perms, but this is up to you.

Script

////////////////////////////////////////////////////////////////////////////////////////
//
//
//      Tweenster Alpha Control API V3
//
//      License: Creative Commons Attribution-ShareAlike 4.0 International
//
//      Copyright (2018) Meshmerized and CasperTech Ltd
//
//
////////////////////////////////////////////////////////////////////////////////////////


//=======================================================================
//
//  INSTRUCTIONS
//
//=======================================================================
//
//  The V3 Alpha API has been made much easier to use.
//
//  Simply set the alphas you want on Tweenster. Then, on the HUD,
//  go to OPTIONS and then 5 for "Output Auto Alpha Code".
//
//  Then, simply paste the code into the AutoAlpha function below
//  (between the { } ).
//
//  Example code is provided, just delete the stuff that's there already.

AutoAlpha()
{
    // ------ PASTE CODE BELOW ------
    SendAlphas(1, 33377316, 255, 0);
    SendAlphas(1, 256, 115, 140);
    SendAlphas(1, 33554432, 24, 231);
    SendAlphas(2, 8192, 25, 230);
    SendAlphas(2, 16384, 3, 252);
    // ------ PASTE CODE ABOVE ------
}   

//=======================================================================

//=======================================================================
//
//  Don't modify anything below this line unless you know what you're doing
//
//=======================================================================

integer on = FALSE;

list unsetCommands = [];
list setCommands = [];
string unsetCommand = "";
string setCommand = "";

string passCode = "";

SendAlphas(integer set, integer partMask, integer faceMask, integer alphaMask)
{
    setCommands += [llDumpList2String([set, partMask, faceMask, alphaMask], "\n")];
    unsetCommands += [llDumpList2String([set, partMask, faceMask, (~alphaMask) &~ 4294967040], "\n")];
}

SendCommand(string command)
{
    if (passCode == "")
    {
        llOwnerSay("AutoAlpha: Warning: Tried to send command without knowing the passcode..");
    }
    llRegionSayTo(llGetOwner(), 10101, "TWEENSTERV3\n3\n" + llGetObjectName()+"\n" + llSHA1String(passCode + (string)llGetKey()) + "\n" + command);
}

Apply(integer on)
{
    if (on)
    {
        unsetCommands = [];
        setCommands = [];
        AutoAlpha();
        setCommand = llDumpList2String(setCommands, "\n");
        unsetCommand = llDumpList2String(unsetCommands, "\n");
        llRegionSayTo(llGetOwner(), 10101, "TWEENSTERV3\n2");
    }   
    else
    { 
        SendCommand(unsetCommand);
    }
}

default
{
    state_entry()
    {    
        //The Tweenster body will talk back to us on port 10102, so this sets
        //up a listener
        llListen( 10102, "", "", "" );
    }
    attach(key id)
    {
        if (id != NULL_KEY)
        {
            // We wait 5 seconds before applying alphas to give other attachments time to unset theirs
            llSleep(5.0);
            Apply(TRUE); 
        }       
        else if (unsetCommand != "")
        {
            Apply(FALSE);
        }
    }
    listen(integer channel, string name, key id, string message)
    {
        //IMPORTANT : Always check that the message has come from the correct owner
        if (channel == 10102 && llGetOwnerKey(id) == llGetOwner())
        {
            list message_list = llParseStringKeepNulls(message, ["\n"], []);
            if (llList2String(message_list,0)!="TWEENSTERV3") return;
            
            integer cmd = llList2Integer(message_list,1);

            if (cmd == 1)
            {
                list masks = llParseStringKeepNulls(llList2String(message_list,2), ["|"], []);
            
                // These are no longer used by the Auto Alpha system.
                // However, they are available to you to use if you wish.
            }
            else if (cmd == 2)
            {
                passCode = llList2String(message_list, 2);
                SendCommand(setCommand);
            }
            if (cmd == 3)
            {
                //Alphas have been set successfully        
            }
        }
    }
}