Populating prims in a link set
|
|
Miro Collas
Registered User
Join date: 28 May 2007
Posts: 73
|
08-06-2008 22:32
Hi,
I would like to populate a set of prims in a link set with one or more predefined items. I know this can be done, but I can't for the life of me find how.
Similarly, I need to know how to reverse this process, ie, delete one or more items from all prims in a link set.
Any help would be much appreciated - thanks in advance!
-- Miro
|
|
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
|
08-06-2008 23:37
Hmm... list ToPopulate = [2, 4, 8, 16]; integer i = llGetListLength(ToPopulate) - 1; for (; i >= 0; --i) { llGiveInventory(llGetLinkKey(llList2Integer(ToPopulate, i)), "Population"  ; } That should do it to stuff the child prims. Note that scripts can't be given this way if you want them to keep on running. Two solutions however exist. One is complicate, the other is stupid. As for removing guts from your child prims, you can't do it without putting at least a bomb in their belly... A script, if you prefer.  And since the script can delete itself too, you can totally clean the place. Here is all you need to know about prim inventory: http://wiki.secondlife.com/wiki/Category:LSL_InventoryPlay a little with all you'll see and come back for more questions...
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
08-06-2008 23:39
To fill all prims in a link set with 'this script' do this: for ( i = 2; i <= llGetNumberOfPrims(); i++ ) llGiveInventory( llGetLinkKey( i ), llGetScriptName()); To remove 'this script' from a prim do this: llRemoveInventory( llGetScriptName() ); These are the ingredients. Now make your own cocktail  Happy scripting
_____________________
From Studio Dora
|
|
Miro Collas
Registered User
Join date: 28 May 2007
Posts: 73
|
08-07-2008 00:37
Thanks you both for your replies! OK, so, I got populating the prims. But removing contents still has me stumped. A script stops running when moved to another prim? I tried this: nuke_all_scripts() { llRemoveInventory("TEST"); llRemoveInventory("TEST 1"); llRemoveInventory("Blargh"); llRemoveInventory( llGetScriptName() ); }
default { state_entry() {
}
touch_start(integer total_number) { integer i = 0; llOwnerSay("Populating Prims"); for ( i = 2; i <= llGetNumberOfPrims(); i++ ) llGiveInventory( llGetLinkKey( i ), llGetScriptName()); llOwnerSay("Starting to clean..."); llMessageLinked(LINK_SET, 0, "", ""); } link_message(integer sender, integer num, string str, key id) { if(llGetLinkNumber() != 1) nuke_all_scripts(); } }
Yes, the prims are filling with crud as I test. 
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
08-07-2008 01:27
From: Miro Collas OK, so, I got populating the prims. But removing contents still has me stumped. A script stops running when moved to another prim? You can't MOVE a script (complete with its current runtime state) to another prim at all. You can COPY a script to another prim, but just like when you drag a script anew from your inventory, it starts execution as if it had just been reset. I'm pretty sure that even if you "move" a script for which you don't have copy permissions its state is completely reset and it starts afresh. If the script is copied with llGiveInventory() or llGiveInventoryList(), it is not started until the user manually intervenes (open the script and check the "Running" box or use Tools -> Set Scripts To Running In Selection). You can use llRemoteLoadScriptPin() instead to actually get it running once it is copied, but since the script PIN has to be set before-hand in the target prim from a script using llSetRemoteScriptAccessPin(), you may have kind of a chicken-and-the-egg problem.
|
|
Miro Collas
Registered User
Join date: 28 May 2007
Posts: 73
|
08-07-2008 02:01
From: Hewee Zetkin You can't MOVE a script (complete with its current runtime state) to another prim at all. You can COPY a script to another prim, but just like when you drag a script anew from your inventory, it starts execution as if it had just been reset. I'm pretty sure that even if you "move" a script for which you don't have copy permissions its state is completely reset and it starts afresh. OK, that much I guessed - which is why I sent a message to the linked prims. But... if it isn't even started... From: Hewee Zetkin If the script is copied with llGiveInventory() or llGiveInventoryList(), it is not started until the user manually intervenes (open the script and check the "Running" box or use Tools -> Set Scripts To Running In Selection). You can use llRemoteLoadScriptPin() instead to actually get it running once it is copied, but since the script PIN has to be set before-hand in the target prim from a script using llSetRemoteScriptAccessPin(), you may have kind of a chicken-and-the-egg problem. Hum, ok, I know it can be done, I've seen stuff that does it. So.... uhmmm.... how? [begs] -- Miro
|
|
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
|
08-07-2008 07:13
From: Miro Collas Hum, ok, I know it can be done, I've seen stuff that does it. So.... uhmmm.... how? [begs]   But this requires a script in each destination prim to set the PIN, which might defeat the purpose of what you're trying to do.
|