Skip to content

Instantly share code, notes, and snippets.

@antonyfairport
Last active October 6, 2017 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonyfairport/c843f4ea0ff33a4cda3a to your computer and use it in GitHub Desktop.
Save antonyfairport/c843f4ea0ff33a4cda3a to your computer and use it in GitHub Desktop.
//////////////////////////////////////////////////////////////////////
// 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." );
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment