|
Ren Revnik
Registered User
Join date: 1 Nov 2007
Posts: 3
|
07-07-2009 17:44
I create a prim and in its contents I added a few textures and added another prim. I create a script that does something simple like randomly pick one of the textures on a touch then rez the prim with the texture. The problem I am having is how to apply the texture to the prim in the contents without also putting a script into that prim and use the link message functions. Is there a method to do this?
TIA Ren
|
|
Chosen Few
Alpha Channel Slave
Join date: 16 Jan 2004
Posts: 7,496
|
07-07-2009 18:13
I bet someone over in the Scripting Tips forum would know. Good luck. 
_____________________
.
Land now available for rent in Indigo. Low rates. Quiet, low-lag mainland sim with good neighbors. IM me in-world if you're interested.
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
07-07-2009 18:43
You cannot apply a texture to the prim while it is in the contents of another prim. You can only apply the texture after it is rezzed. That's not much of a problem, though. write a script like this .... list MyTextures = ["the UUID of texture #1","the UUID of texture #2","the UUID of texture #3"]; // Make this list as long as you like. default { on_rez(integer start_param) { integer ListLength = llGetListLength(MyTextures); integer PaintWith = (integer)llFrand(ListLength-1); llSetPrimitiveParams([PRIM_TEXTURE,ALL_SIDES,llList2Key(MyTextures,PaintWith),< 0,0,0 >, < 0,0,0 >, PI]); } }
I haven't compiled or tested this, so there might be typing errors. Put this script in the prim that you are going to put in your main prim's contents. You do not need to put the textures in there. Just be sure that you put the UUID of each texture in the list MyTextures. It ought to work. If it does, it will randomly choose a texture from MyTextures each time you rez the prim and will apply it to all sides of it. You will still need to include a script in the main prim that actually rezzes the new prim from contents, of course. ETA: OK, so I did make two tiny typing errors.. Fixed now.. 
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
|
Domino Marama
Domino Designs
Join date: 22 Sep 2006
Posts: 1,126
|
07-08-2009 01:31
From: Ren Revnik I create a prim and in its contents I added a few textures and added another prim. I create a script that does something simple like randomly pick one of the textures on a touch then rez the prim with the texture. The problem I am having is how to apply the texture to the prim in the contents without also putting a script into that prim and use the link message functions. Is there a method to do this?
TIA Ren You can do this by temporarily linking the rezzed prim to the rezzer, setting the texture via llSetLinkPrimitiveParams, then breaking the link. This way it can be done with a single script in the rezzer and the rezzed prim never needs a script. The git version of my Blender scripts for sculpties use this method to create a builder script to recreate linksets in SL. Here's an example that would build a two prim linkset. quote this message for spacing string base = "Prim"; list textures = ["Holes", "Texture", "Holes.001"]; vector myPos; integer tI; string tS;
integer isKey(key in) { if(in) return 2; return (in == NULL_KEY); }
addPrim() { llRezObject(base, myPos, ZERO_VECTOR, ZERO_ROTATION, 0 ); }
default { state_entry() { if ( llGetInventoryType( base ) != INVENTORY_OBJECT ) { llOwnerSay( "Please add a prim called \"" + base + "\" to my contents" ); state needs_something; } tI = llGetListLength( textures ); while ( tI ){ if ( isKey( tS = llList2String( textures, tI = ~-tI ) ) == 0 ) { if ( llGetInventoryType( tS ) != INVENTORY_TEXTURE ) { llOwnerSay( "Please add texture \"" + tS + "\" to my contents" ); state needs_something; } } } llRequestPermissions( llGetOwner(), PERMISSION_CHANGE_LINKS ); }
run_time_permissions( integer perm ) { if ( perm & PERMISSION_CHANGE_LINKS ) { state ready; } else { llOwnerSay( "You must give link permissions for the build to work. Click to try again." ); state needs_something; } } }
state ready { state_entry() { llOwnerSay( "Ready to build. Click to start." ); }
touch_start( integer num ) { if ( llDetectedKey ( 0 ) == llGetOwner() ) { state build; } } }
state build { state_entry() { myPos = llGetPos(); llSetRot( ZERO_ROTATION ); addPrim(); }
object_rez( key id ) { llCreateLink(id, TRUE ); }
changed( integer change ) { if ( change & CHANGED_LINK ) { tI = ~-llGetNumberOfPrims(); if ( tI == 1 ) { llSetLinkPrimitiveParams( 2, [ PRIM_TYPE, PRIM_TYPE_SCULPT, "Holes.001", PRIM_SCULPT_TYPE_CYLINDER, PRIM_SIZE, < 0.99834, 0.83556, 1.91821 >, PRIM_ROTATION, < 0.00000, 0.00000, 0.00000, 1.00000 >, PRIM_POSITION, < 0.00000, -0.29278, 0.54007 >, PRIM_TEXTURE, ALL_SIDES, "Texture", < 1.0, 1.0, 0.0 >, < 0.0, 0.0, 0.0 >, 0.0 ] ); addPrim(); } else if (tI > 0 ) { llSetLinkPrimitiveParams( 2, [ PRIM_TYPE, PRIM_TYPE_SCULPT, "Holes", PRIM_SCULPT_TYPE_CYLINDER, PRIM_SIZE, < 0.99834, 0.83556, 1.91821 >, PRIM_ROTATION, < 0.00000, 0.00000, 0.00000, 1.00000 >, PRIM_POSITION, < 0.00000, -0.29278, 0.54007 >, PRIM_TEXTURE, ALL_SIDES, "Texture", < 1.0, 1.0, 0.0 >, < 0.0, 0.0, 0.0 >, 0.0 ] ); llBreakLink( 1 ); } else { llOwnerSay( "Finished!" ); state ready; } } } }
state needs_something { on_rez( integer num) { state default; }
changed( integer change ) { if ( change & CHANGED_INVENTORY ) { state default; } }
touch_start( integer num ) { if ( llDetectedKey ( 0 ) == llGetOwner() ) { state default; } } }
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
I don't want to encourage cross-posting, but ...
07-09-2009 11:40
just in case someone is following this thread, there's also some follow-up in the Scripting Tips forum, where the OP also posted ....  .
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|