Texture parameter changer
// -------------------------------------------------------------------------------------------------
// texture_params_changer.lsl version 1.0 by Lacuna Arado
// -------------------------------------------------------------------------------------------------
// This script saved me a lot of time by avoiding the need to adjust several prims individually. In
// this instance, I needed to proportionally adjust the texture repeats and offsets for all of the
// wooden posts (cylinder prims) within a big barn object. This script can be easily modified to
// suit other similar purposes. Try it on a test object before you monkey with your favorite castle.
// -------------------------------------------------------------------------------------------------
// Here is the run-down of what this particular script does:
// Scope: only face #1 of cylinder prims within the linkset are affected
// Scope: the cylinder prims must have the planks04 texture on face #1
// Scope: only cylinder prims sized larger than <0.125, 0.125, 1.0> are affected
// Action: sets horizontal repeats to 0.5
// Action: sets vertical repeats to the prim's side z length divided by 2
// Action: sets horizontal offset to 0.5
// Limitation: texture UUIDs are grid-specific and thus are hard-coded
// -------------------------------------------------------------------------------------------------
// This script is distributed as "FREEWARE" and is available as a public domain asset for any and
// all to use and modify as they deem fitting. The author of this software accepts no
// responsibility for damages resulting from the use of this script and makes no warranty or
// representation, either express or implied, including but not limited to, any implied warranty of
// merchantability or fitness for a particular purpose. This script is provided "AS IS", and you,
// its user, assume ALL risks and liabilities when using it.
default
{
state_entry()
{
}
touch_end(integer num)
{
integer i;
llOwnerSay("Please wait while I set the texture parameters...");
i = llGetNumberOfPrims();
for (; i >= 0; --i) // loop through all prims of the linkset
{
list typeParams = llGetLinkPrimitiveParams(i,[PRIM_TYPE]);
if (llList2Integer(typeParams, 0) == 1) // prim type = 1 for cylinder
{
// get texture of face #1
list textureParams = llGetLinkPrimitiveParams(i, [PRIM_TEXTURE, 1]);
key id = llList2Key(textureParams, 0);
if (id == "1d00b7b0-9e12-4398-b3f1-e52e39a6fa72") // planks04 texture
{
list sizeParams = llGetLinkPrimitiveParams(i, [PRIM_SIZE]);
vector size = llList2Vector(sizeParams, 0);
// only do this to prims greater than this size:
if ((size.x > 0.125) && (size.y > 0.125) && (size.z > 1.0))
{
// vector repeats = llList2Vector(textureParams, 1);
// vector offset = llList2Vector(textureParams, 2);
vector repeats = <0.5, size.z/2, 0>;
vector offset = <0.5, 0, 0>;
float rot = llList2Float(textureParams, 3) * RAD_TO_DEG;
llSetLinkPrimitiveParamsFast(i, [PRIM_TEXTURE, 1, id, repeats, offset, rot]);
// uncomment the line below if you want run-time debug info
// llOwnerSay("link # " + (string) i + " set to " + (string) repeats);
}
}
}
}
llOwnerSay("Done!");
llRemoveInventory(llGetScriptName());
}
}