Warning: Parameter 1 to Language::getMagic() expected to be a reference, value given in /var/www/sda/2/c/digigrids/wiki/includes/StubObject.php on line 58

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/sda/2/c/digigrids/wiki/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /var/www/sda/2/c/digigrids/wiki/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/sda/2/c/digigrids/wiki/includes/MagicWord.php on line 675

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/sda/2/c/digigrids/wiki/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /var/www/sda/2/c/digigrids/wiki/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/sda/2/c/digigrids/wiki/includes/MagicWord.php on line 675

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/sda/2/c/digigrids/wiki/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /var/www/sda/2/c/digigrids/wiki/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/sda/2/c/digigrids/wiki/includes/MagicWord.php on line 675

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/sda/2/c/digigrids/wiki/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /var/www/sda/2/c/digigrids/wiki/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/sda/2/c/digigrids/wiki/includes/MagicWord.php on line 675
LlRemoteLoadScriptPin - DigiWiki

LlRemoteLoadScriptPin

De DigiWiki.

Ligne 107 : Ligne 107 :
}
}
</lsl>
</lsl>
 +
 +
===Exemple 4===
 +
llRemoteLoadScriptPin Example (CC BY License)<br />
 +
llRemoteLoadScriptPin is very powerful, but can be daunting to get your head around at first.<br />
 +
Put this is script in the 'Original' prim. Be sure to call it 'Super Important Script' (script names are in the headers).
 +
<lsl>
 +
// 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);
 +
        }
 +
    }
 +
 +
}
 +
</lsl>
 +
Next up, the 'Updater' prim, and the update script:
 +
<lsl>
 +
// 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);
 +
            }
 +
        }
 +
    }
 +
}
 +
</lsl>
 +
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'.<br />
 +
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).<br />
 +
Here's the script below with the 'update' (ie, incrementing version numbers)
 +
<lsl>
 +
// 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);
 +
        }
 +
    }
 +
 +
}
 +
</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.

Version du 24 avril 2015 à 19:31

Outils personnels
donate
Google Ads