Table of Contents

Introduction

This script was tested and works on OpenSim version 0.7.4!

The following script generates tiles by traversing a space with the dimensions: $\verb+BOARD_WIDTH+ \times \verb+BOARD_HEIGHT+ \times \verb+BOARD_DEPTH+$ by rezzing an object, with the scale OBJECT_SCALE, from the primitive's inventory with the time-delay DELAY between each rez.

The expected result should be a three-dimensional structure with blocks:


            BOARD_HEIGHT +z|
                           |
                           +-------+
                          /|_|_| |/|
                         / |_|_|_/_|
                        /  |_| |/|_|
                       /   +---/---+----------------->
                      /   /   /   /  BOARD_WIDTTH +x
                     /   /   /   /
                    +-------+   /
                    |  /    |  /
                    | /     | /
                    |/      |/
                    +-------+
                   /
    BOARD_DEPTH +y/

Notes

This script should function properly in an OpenSim environment. Initially it had been designed to use a loop instead of a timer. However, due to some not well-founded choices, event handlers in OpenSim are killed by default after a certain time period. They should not. Handers should not go away. Just the event that triggers the handler does, after a time period.

Setup

In order to use this script:

  1. Create a primitive.
  2. Drop another primitive that you wish to rez at every stop inside the primitive from Step 1.
  3. Copy and configure the speed with attention to the configuration section.
  4. Touch the primitive from Step 1 to start rezzing the object inside it from Step 2.

You may abort the rezzing procedure by touching the object again.

Code

spatial_tile_generator.lsl
//////////////////////////////////////////////////////////
//   (C) Wizardry and Steamworks 2011, license: GPLv3   //
// Please see: http://www.gnu.org/licenses/gpl.html     //
// for legal details, rights of fair usage and          //
// the disclaimer and warranty conditions.           //
//////////////////////////////////////////////////////////
 
//////////////////////////////////////////////////////////
//                   CONFIGURATION                      //
//////////////////////////////////////////////////////////
// The height of the generated board.
integer BOARD_HEIGHT = 2;
// The width of the generated board.
integer BOARD_WIDTH = 2;
// The depth of the board.
integer BOARD_DEPTH = 2;
// The delay between rezzing the object in the primitive.
float DELAY = .5;
// Set this to the scale of the primitive inside the object.
vector OBJECT_SCALE = <.5,.5,.5>;
 
//////////////////////////////////////////////////////////
//                      INTERNALS                       //
//////////////////////////////////////////////////////////
integer runner = 1;
integer gitra = 0;
integer gitrb = 0;
integer gitrc = 0;
vector tilePos = ZERO_VECTOR;
 
default {
 
    state_entry() {
        llSay(0, "Click the glowing prim to deploy more tiles.");
    }
 
    touch_start(integer total_number) {
        // Sanity.
        if(BOARD_HEIGHT*BOARD_WIDTH < 1) {
            llSay(DEBUG_CHANNEL, "Sorry, the width and height have to be larger than zero. Aborting.");
            return;
        }
        if(llGetInventoryName(INVENTORY_OBJECT, 0) == "") {
            llSay(DEBUG_CHANNEL, "Sorry, I could not find an object in the inventory to rez. Aborting.");
            return;
        }
        tilePos = llGetPos();
        state deploy;
    }
}
 
state deploy {
 
    state_entry() {
        llSay(0, "Please wait, deploying prims. Touch To stop...");
        llSetTimerEvent(DELAY);
    }
    touch_start(integer num) {
        llSetTimerEvent(0);
        state default;
    }
    timer() {
        llSetTimerEvent(0);
        if(runner > BOARD_WIDTH*BOARD_HEIGHT*BOARD_DEPTH+1) {
            state default;
            return;
        }
        if(gitrc < BOARD_DEPTH) {
            if(gitrb < BOARD_HEIGHT) {
                if(gitra < BOARD_WIDTH-1) {
                    llRezObject(llGetInventoryName(INVENTORY_OBJECT,0),tilePos,ZERO_VECTOR,ZERO_ROTATION,++runner);
                    tilePos.x += OBJECT_SCALE.x;
                    llSetPos(tilePos);
                    ++gitra;
                    llSetTimerEvent(DELAY);
                    return;
                }
                llRezObject(llGetInventoryName(INVENTORY_OBJECT,0),tilePos,ZERO_VECTOR,ZERO_ROTATION,++runner);
                if(gitrb+1 >= BOARD_HEIGHT) {
                    OBJECT_SCALE.x *= -1;
                    ++gitrb;
                    gitra = 0;
                    llSetTimerEvent(DELAY);
                    return;
                }
                tilePos.z += OBJECT_SCALE.z;
                llSetPos(tilePos);
                OBJECT_SCALE.x *= -1;
                ++gitrb;
                gitra = 0;
                llSetTimerEvent(DELAY);
                return;
            }
            tilePos.y += OBJECT_SCALE.y;
            OBJECT_SCALE.z *= -1;
            llSetPos(tilePos);
            ++gitrc;
            gitrb=0;
            gitra=0;
            llSetTimerEvent(DELAY);
            return;
        }
    }
}

secondlife/spatial_tile_generator.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.