This script is for a prim measuring 2m x 2m x4m (length width and height respectively).
It changes between a floor or a wall when touched.
The concept is for a grid of these prims, at least 25 (5 rows of 5) to build a labyrinth game.
// PRIM RESIZE Script
float HEIGHT_SMALL = 0.1;
float HEIGHT_LARGE = 4.0;
vector SIZE = <2.0, 2.0, 0.0>; // X and Y are fixed, Z will change
vector POSITION_SMALL = <0.0, 0.0, 0.05>; // Offset for 0.1m size
vector POSITION_LARGE = <0.0, 0.0, 2.0>; // Offset for 4m size
default
{
touch_start(integer total_number)
{
vector basePos = llGetPos(); // Establish base position at every click
vector currentSize = llGetScale();
vector newSize;
vector newPosition;
if (currentSize.z == HEIGHT_LARGE)
{
newSize = <SIZE.x, SIZE.y, HEIGHT_SMALL>;
newPosition = basePos + POSITION_SMALL - POSITION_LARGE; // Adjust relative to current position
}
else
{
newSize = <SIZE.x, SIZE.y, HEIGHT_LARGE>;
newPosition = basePos + POSITION_LARGE - POSITION_SMALL; // Adjust relative to current position
}
llSetScale(newSize);
llSetPos(newPosition);
}
}