Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

linking objects to work together with the same script

Dale Harmison
Registered User
Join date: 26 Dec 2005
Posts: 59
07-17-2006 06:47
hi all i dont know how to explain it right but im tryin to find a thing that will help me....
i want to put textures which will change every time i touch it in about a 20+ prim thing and id like to know how to like link them together and instead of puttin the same script into all the prims would it be possible to put it into just one or two or free of that object?
Also i need to know who to link all the prims script wise cause i tried doing that before and only the prim id click on would change the texture not the rest :(
if you understand this please help me.
thank you for your time!
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
07-17-2006 08:06
Afraid to change textures you will need a script in each prim you intend to change, sadly there's no llSetLinkTexture :<

to trigger changes in more than one prim, look up llMessageLinked() and relevant event: http://secondlife.com/badgeo/wakka.php?wakka=llMessageLinked ... basically have the touched prim send out message to link set, and then scripts in each prim react to it by changing their own texture.
Adriana Caligari
Registered User
Join date: 21 Apr 2005
Posts: 458
07-17-2006 08:29
CODE

send_message( key pid, string pname )
{
llMessageLinked( LINK_SET,0,pname,pid);
}

process_touch( key tid, string tname )
{
// put your touch processing in here
integer no = llGetInventoryNumber( INVENTORY_TEXTURE );
string name = llGetInventoryName( INVENTORY_TEXTURE,(integer)llFrand( no ));
llSetTexture( name,ALL_SIDES );
}

init()
{
//debug
llOwnerSay ( (string)llGetLinkNumber() + " Ready" );
}

default
{
state_entry()
{
init();
}
on_rez( integer r )
{
init();
}
changed( integer c )
{
if ( CHANGED_OWNER & c )
{
llResetScript();
}
}
touch_start( integer t )
{
// send message to all objects in link set to fire touch
send_message( llDetectedKey(0), llDetectedName(0) );
}
link_message( integer set, integer to, string mess, key id )
{
process_touch( id,mess );
}
}



Put that in all your linked objects and whenevr you touch they will all process touch.

A little on the crude side - but it works.
_____________________
Maker of quality Gadgets
Caligari Designs Store