Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Script to Prim Question

Shayna Korobase
Registered User
Join date: 8 May 2007
Posts: 454
11-15-2008 21:38
Ok this may seem liek a strange question. Is there a way to add a single script to multiple prims without having to do it prim by prim? For example... let's say I have a sword that needs a holster script and the script has to go in al 50 prims.

I'm pretty sure the answer is no but some tmes new tool come out I'm unaware of.

Thanks :-)
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
11-15-2008 23:27
llRemoteLoadScriptPin, put a script in each prim setting the pin once then use this to update the script.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
11-16-2008 01:27
You can also use llGiveInventory() to populate, say, all prims in an object, then manually set all the scripts to running using Tools -> Set All Scripts To Running In Selection. Remember to make it a script that'll set the script PIN so you can do it all automatically afterward. :)
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
11-16-2008 01:56
If I may... Putting a script in every prim to show/hide a sword is very inefficient.

llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES); // Show

llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES); // Hide

That will do the trick.

That can apply also to the handle of the sword in the sheath if it's a separate attachment. (left/right pectoral or spine/belly don't move relatively to each other... IIRC)

If you don't have attachments points to waste, you can still use only one llSetLinkAlpha() to show the handle in the sheath.

Hiding is more tricky but, since llSetLinkAlpha() has no delay, you may consider first hiding the whole attachment and then restoring the sheath thanks to a list containing all the link numbers of its prims.

Putting a script in every prim must be the very last solution when nothing else works.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
11-16-2008 08:18
From: Kaluura Boa
Hiding is more tricky but, since llSetLinkAlpha() has no delay, you may consider first hiding the whole attachment and then restoring the sheath thanks to a list containing all the link numbers of its prims.

Putting a script in every prim must be the very last solution when nothing else works.

Actually using llSetLinkAlpha() on a large list of prims is incredibly slow compared to having a script in each prim that responds to a link message. In an object with many prims (I made a bow with something like 70 prims, with about 20% of them being shared between drawn and fired positions) it can be the difference between seeing prims slowly pop out of visibility one by one and a near instantaneous looking change in position. Unfortunate but true. If you can get away with a single script great, but I wouldn't expect to be able to do that in anything but a pretty trivial project.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
11-16-2008 08:47
From: Shayna Korobase
. Is there a way to add a single script to multiple prims without having to do it prim by prim?


From Emma Nowhere's invaluable script, Fix Small Prims http://wiki.secondlife.com/wiki/Fix_Small_Prims
CODE
GiveScriptToLinkedPrims()
{
integer p = llGetNumberOfPrims();
integer i = 0;
for (i = 2; i <= p; i++)
{
key prim = llGetLinkKey(i);
llGiveInventory(prim, llGetScriptName());
}
}
Having pasted that function into the script you want to propagate and called it in whatever way you want, you need to take the object back into your inventory, re-rez it and then set scripts to running from the Tools menu.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-16-2008 09:12
From: Shayna Korobase
Ok this may seem liek a strange question. Is there a way to add a single script to multiple prims without having to do it prim by prim? For example... let's say I have a sword that needs a holster script and the script has to go in al 50 prims.

I'm pretty sure the answer is no but some tmes new tool come out I'm unaware of.

Thanks :-)

Why exactly do you need to put 50 scripts into the same object?

One single script in an object made of 50 prims would still show or hide the object for example.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Shayna Korobase
Registered User
Join date: 8 May 2007
Posts: 454
11-18-2008 06:53
From: Jesse Barnett
Why exactly do you need to put 50 scripts into the same object?

One single script in an object made of 50 prims would still show or hide the object for example.


Thank you all for your thoughts, opinions and advice.

To answer this question. Let's say I have a Katana Sheath. When I unsheath it the handle only needs to vanish. To do this I insert the script only in the parts I want effected.

Thanks.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
11-18-2008 07:16
Wouldn't it be great to have child-linksets? :)
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
11-18-2008 16:09
Another solution, combine all your textures onto a single 'multiple-textures' texture, then apply offsets to align each texture section properly on your object. Make a second, identical texture with the sections used for the "handle" erased (transparent).

With a single script, you only need to switch between the on/off textures.

This method has drawbacks. It doesn't work if you use repeating textures (unless you build the repeats into the single 'multiple-textures' texture). And, of course, the usual caveats regarding 32-bit textures.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-19-2008 11:10
From: Haruki Watanabe
Wouldn't it be great to have child-linksets? :)

and tattoo layers for tattoos, and a way to correlate attachment locations to the world....
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
jamieparsons Lemon
undergrad n00b
Join date: 5 Nov 2008
Posts: 36
Is this possible?
11-20-2008 07:18
When an agent collides with an object, the object moves appropriately but only upto a certain point then glides back into the original position.

Is this possible?