LlRemoteLoadScriptPin

De DigiWiki.

(Différences entre les versions)
Ligne 159 : Ligne 159 :
         }
         }
     }
     }
-
 
}
}
</lsl>
</lsl>
Ligne 232 : Ligne 231 :
integer start_parm;  
integer start_parm;  
string version_command = "version";
string version_command = "version";
-
 
default
default
Ligne 261 : Ligne 259 :
         }
         }
     }
     }
-
 
}
}
</lsl>
</lsl>
Final Note: This will update every copy of the 'Original' copy in the sim, with a small delay Think: a sim of rental boxes or vendors! There's a 3 second delay built into the llRemoteLoadScriptPin function, however.
Final Note: This will update every copy of the 'Original' copy in the sim, with a small delay Think: a sim of rental boxes or vendors! There's a 3 second delay built into the llRemoteLoadScriptPin function, however.

Version du 24 avril 2015 à 19:33

Exemple 1

Script copier

// Copy a script to the second prim
 
integer PIN = 1341134;
 
default
{
    state_entry()
    {
        llRemoteLoadScriptPin( llGetLinkKey(2), "some script", PIN, TRUE, 0xBEEEEEEF);
    }
}

Pin setter

Simple script used for setting the pin for a prim, so you can later send scripts to it with llRemoteLoadScriptPin.

// Child Prim PIN setter
 
integer PIN = 1341134;
 
default
{
    state_entry()
    {
        llOwnerSay(llGetObjectName() + " : " + (string)llGetKey() + " is ready to accept a describer script using the agreed upon PIN.");
        llSetRemoteScriptAccessPin(PIN);
    }
}

Exemple 2

// This example will be of two linked prims
 
default
{
    touch_start(integer total_number)
    {
        llGiveInventory(llGetLinkKey(2), "foo"); 
        llRemoteLoadScriptPin(llGetLinkKey(2), "foo", 165, TRUE, 0);
    }
}
 
// What this is does is send the script "foo" and the  'pin' 165 to prim 2 and set the script running when touched.
// The receiver script ~/HAS/~ to be in the other prim before you touch it otherwise it will say illegal transfer
 
// The receiver script will have 
default
{
    state_entry()
    {
        llSetRemoteScriptAccessPin(165);
    }
}

Exemple 3

// Simple pin configuration for allowing other scripts to update the internal script 
// Use an arbitrary PIN
 
integer SCRIPT_PIN = 7589273495872;
 
default
{
    state_entry()
    {
        llSetRemoteScriptAccessPin(SCRIPT_PIN); 
    }
}
// Simple update script to update the given script name to each of the child-prims in a linked set 
 
integer SCRIPT_PIN = 7589273495872; 
string SCRIPT_TO_UPDATE = "updated_script";
 
UpdatePrims()
{
    integer num_prims = llGetNumberOfPrims(); 
 
    integer i; 
    for (i = 2; i <= num_prims; i++)
    {
        key prim_key = llGetLinkKey (i); 
        llOwnerSay("Updating prim #" + (string)(i)); 
        llRemoteLoadScriptPin (prim_key, SCRIPT_TO_UPDATE, SCRIPT_PIN, TRUE, 0);
    }
    llOwnerSay("Updated " + (string)(num_prims - 1) + " prims"); 
}
 
default
{
    state_entry()
    {
        llListen (9, "", llGetOwner(), "update");
    }
 
    listen(integer channel, string name, key id, string message)
    {
        UpdatePrims(); 
    }
}

Exemple 4

llRemoteLoadScriptPin Example (CC BY License)
llRemoteLoadScriptPin is very powerful, but can be daunting to get your head around at first.
Put this is script in the 'Original' prim. Be sure to call it 'Super Important Script' (script names are in the headers).

// llRemoteLoadScriptPin Example 
// script name: Super Important Script
// by Reality Control
// last revision 20091010
//
// This Code is licensed under the Creative Commons Attribution 3.0 License
//      http://creativecommons.org/licenses/by/3.0/us/
//      (Basically: Please credit me in the product documentation, or 
//      monkeys will poke you with sharp pointed sticks when you die)
//
integer listen_handle;
integer script_pin = 2001;
integer channel_in = -792;
integer channel_out = -792;
integer version = 1;
integer start_parm; 
string version_command = "version";
 
 
default
{
    state_entry()
    {
        start_parm = llGetStartParameter(); // will be 0 when rezzed from inventory
        llSetRemoteScriptAccessPin(script_pin);
        listen_handle = llListen(channel_in, "", NULL_KEY, version_command);
        llSetText("Version: " + (string)version + "\nParameter: " + (string)start_parm, <1.0, 1.0, 1.0>, 1.0);
        // ...etc
    }
 
    changed(integer mask)
    {
        if(mask & CHANGED_OWNER)
        {
            llResetScript();
        }
    }
 
    listen(integer channel, string name, key id, string message)
    {
        if (llGetOwner() == llGetOwnerKey(id)) 
        {
            //llOwnerSay((string)channel + "::" + (string)name + "::" + (string)id + "::" + message);
            llRegionSay(channel_out, (string)version);
        }
    }
}

Next up, the 'Updater' prim, and the update script:

// llRemoteLoadScriptPin Example
// Script Name: Updater Script
// by Reality Control
// last revision 20091010
//
// This Code is licensed under the Creative Commons Attribution 3.0 License
//      http://creativecommons.org/licenses/by/3.0/us/
//      (Basically: Please credit me in the product documentation, or 
//      monkeys will poke you with sharp pointed sticks when you die)
//
integer listen_handle;
integer script_pin = 2001;
integer channel_in = -792;
integer channel_out = -792;
integer current_version = 2;
integer start_parm = 23;
string version_command = "version";
string script_name = "Super Important Script";
 
default
{
    state_entry()
    {
        listen_handle = llListen(channel_in, "", NULL_KEY, "");
        llSetText("Updater: Version " + (string)current_version, <1.0, 1.0, 1.0>, 1.0);
    }
 
    touch_start(integer total_number)
    {
        llRegionSay(channel_out, version_command);
    }
 
    listen(integer channel, string name, key id, string message)
    {
        if (llGetOwner() == llGetOwnerKey(id))
        {
            if ((integer)message >= current_version) // up to date
            {
                llOwnerSay(name + " (UUID:" + (string)id + ") is up to date.");
            } else {
                llOwnerSay(name + " (UUID:" + (string)id + ") is being updated. Currently running Version " + message);
                llRemoteLoadScriptPin(id, script_name, script_pin, TRUE, start_parm);
            }
        }
    }
}

See how the script_name variable is 'Super Important Script'? That's the name of the script we're going to transfer into the 'Original' prim. Make a 2nd script inside the 'Updater' prim and name it 'Super Important Script'.
Also, make sure the 'running' box is unchecked, as you don't want it running in the updater, the llRemoteLoadScriptPin function will turn it on (see the wiki for details on how that works).
Here's the script below with the 'update' (ie, incrementing version numbers)

// llRemoteLoadScriptPin Example 
// script name: Super Important Script
// by Reality Control
// last revision 20091010
//
// This Code is licensed under the Creative Commons Attribution 3.0 License
//      http://creativecommons.org/licenses/by/3.0/us/
//      (Basically: Please credit me in the product documentation, or 
//      monkeys will poke you with sharp pointed sticks when you die)
//
integer listen_handle;
integer script_pin = 2001;
integer channel_in = -792;
integer channel_out = -792;
integer version = 2;
integer start_parm; 
string version_command = "version";
 
default
{
    state_entry()
    {
        start_parm = llGetStartParameter(); // will be 0 when rezzed from inventory
        llSetRemoteScriptAccessPin(script_pin);
        listen_handle = llListen(channel_in, "", NULL_KEY, version_command);
        llSetText("Version: " + (string)version + "\nParameter: " + (string)start_parm, <1.0, 1.0, 1.0>, 1.0);
        // ...etc
    }
 
    changed(integer mask)
    {
        if(mask & CHANGED_OWNER)
        {
            llResetScript();
        }
    }
 
    listen(integer channel, string name, key id, string message)
    {
        if (llGetOwner() == llGetOwnerKey(id)) 
        {
            //llOwnerSay((string)channel + "::" + (string)name + "::" + (string)id + "::" + message);
            llRegionSay(channel_out, (string)version);
        }
    }
}

Final Note: This will update every copy of the 'Original' copy in the sim, with a small delay Think: a sim of rental boxes or vendors! There's a 3 second delay built into the llRemoteLoadScriptPin function, however.

Outils personnels
donate
Google Ads