2015-03-27

Quick steps maker

While contemplating an upcoming build the other day the idea for this script popped into my head and, having thought of it, I had to knock it together quickly. Like a few other scripts I've put on here this stems from my use of Mesh Studio, where I'll make mesh objects in-world from lots of prims. This time around I wanted to make some simple stairs.

I've done this before and it's easy enough: rez and size a prim, copy it, move it to the next spot, copy, move to the next spot, and so on. But it'd be easier done with a script, right?

So the Z&A Quick Steps Maker was born. With this you simply rez out as many cubes as you want steps:


Link all the cubes and drop the script into the root prim. When you do so it'll texture the "top" face of the root so you know what direction the stairs will build in.


Next, size the root prim to the size of a step.


Once you're happy with it, touch the linkset and...



...the steps build themselves. If it doesn't quite look right all you need to do is resize the root prim to taste...


...and touch again to have the stairs rebuild:


Of course, a far more sophisticated system could be made where an object rezzes other objects out, building the stairs for you dynamically (could be something like that even exists -- I've not bothered to look), but that wasn't the point of this script. The point here was to knock up something that works quickly and easily for those times where you know what it is you're doing but you just want to save some fingerwork. It also means that there's no need to consider things like the grey-goo fence as it's you making all the prims up front.

Anyway, on the off chance that it's useful to anyone else, here's the script:

//////////////////////////////////////////////////////////////////////
// Z&A Quick Steps Maker
// By Antony Fairport
//
// Z&A Quick Steps Maker - Quickly make steps from a linkset of prims.
//
// While a more sophisticated stair maker can be made that would rez objects
// as it goes, sometimes you just want to create a linkset and have it all
// size and position correctly. This script does that. Here's how it works:
//
// 1) Rez out as many cubes as you need steps.
// 2) Link them all together.
// 3) Drop this script into the root prim.
// 4) Make note of the face that gets textured with arrows. I shows you
// what the step top is and the direction they'll build in.
// 5) Size the root prim to the size you want the steps to be.
// 6) Touch the object and watch all the other prims size and move.
// 7) When you're happy with things, delete this script.
//
// Revision history:
// ------------------------------------------------------------
//
// 2015-03-24
// Initial revision.
//////////////////////////////////////////////////////////////////////
// Default state.
default
{
//////////////////////////////////////////////////////////////////////
// On state entry...
state_entry()
{
// Show the direction we'll be building in.
llSetLinkPrimitiveParamsFast( LINK_ROOT, [
PRIM_TEXGEN, 0, PRIM_TEXGEN_DEFAULT,
PRIM_COLOR, 0, < 1.0, 1.0, 1.0 >, 1.0,
PRIM_TEXTURE, 0, "87b5b2d9-2eff-d1ae-fada-fd5961cac15c", < 1.0, 1.0, 0.0 >, ZERO_VECTOR, 0.0
] );
}
//////////////////////////////////////////////////////////////////////
// Handle a touch.
touch_start( integer _ )
{
// Don't let others mess with the build.
if ( llDetectedKey( 0 ) == llGetOwner() )
{
// Get the number of objects in the linkset.
integer iMax = llGetNumberOfPrims();
// If this is actually a linkset...
if ( iMax > 1 )
{
// Get the dimensions of the root prim. It's the template.
vector vScale = llGetScale();
// For every other prim in the linkset...
integer i;
for ( i = 2; i <= iMax; i++ )
{
// ..size and move it into position.
llSetLinkPrimitiveParamsFast( i, [
PRIM_SIZE, vScale,
PRIM_POS_LOCAL, < vScale.x * ( i - 1 ), 0, vScale.z * ( i - 1 ) >,
PRIM_ROT_LOCAL, ZERO_ROTATION
] );
}
}
else
{
// Not really anything to do here.
llOwnerSay( "This isn't a linkset. Looks like your step is done already." );
}
}
}
}

No comments:

Post a Comment