Butterflies, part 2

Yesterday we talked about a script to add to some cheap copy mod butterflies available on the marketplace to prepare them for use in a rezzer.  Today, we’ll look at the rezzer script and how to put it all together.

Let’s jump in and look at the rezzer script right away.  All we are going to have to do is place this, an optional notecard, and our modified butterflies in a prim, and we’ll be ready to go!  Here’s the script (don’t panic, it’s a little larger than yesterdays!):

 

integer g_rezzed;
integer g_chan = -88503;
integer g_nc_line;
integer g_rez_count;
integer g_pos_count;
integer g_obj_count;
key g_nc_id;
list g_positions;
list g_objects;
string g_nc_name = "config";

default {
    
    on_rez (integer n) {
        llResetScript ();
    }
    
    changed (integer c) {
        if (c & CHANGED_INVENTORY || c & CHANGED_REGION_START) {
            llResetScript ();
        }
    }
    
    state_entry () {
        llRegionSay (g_chan, "SWAT!");
        integer i;
        g_objects = [];
        g_positions = [];
        g_pos_count = 0;
        string name;
        integer n = llGetInventoryNumber (INVENTORY_OBJECT);
        for (i = 0; i < n; i++) { 
            name = llGetInventoryName (INVENTORY_OBJECT, i);
            if (llGetSubString (name, 0, -2) == "butterflys") {
                g_objects += name;
            }
        }
        g_obj_count = llGetListLength (g_objects);
        if (g_obj_count == 0) {
            llOwnerSay ("There are no butterflys objects in the inventory!");
            return;
        }
        g_rezzed = FALSE;
        g_nc_line = 0;
        if (llGetInventoryType (g_nc_name) == INVENTORY_NOTECARD) {
            g_nc_id = llGetNotecardLine (g_nc_name, g_nc_line);
        } else {
            llSetTimerEvent (30.0);
        }
    }

    dataserver (key id, string data) {
        if (id == g_nc_id) {
            if (data != EOF) {
                if (llGetSubString (data, 0, 0) != "#") {
                    g_positions += (vector)data;
                    llRegionSay (g_chan + g_nc_line, "SWAT!");
                }
                g_nc_id = llGetNotecardLine (g_nc_name, ++g_nc_line);
            } else {
                g_pos_count = llGetListLength (g_positions);
                llSetTimerEvent (30.0);
            }
        }
    }

    timer () {
        vector sun = llGetSunDirection ();
        if (sun.z > 0) {
            if (g_rezzed == FALSE) {
                integer i;
                for (i = 0; i < g_pos_count + 1; i++) {
                    llRezObject (llList2String (g_objects, (integer)llFrand (g_obj_count)),
                                 llGetPos () + <0.0, 0.0, 1.5>,
                                 ZERO_VECTOR,
                                 ZERO_ROTATION,
                                 g_chan + i);
                    g_rez_count++;
                }
                g_rezzed = TRUE;
            }
        } else {
            if (g_rezzed == TRUE) {
                integer i;
                for (i = 0; i < g_pos_count + 1; i++) {
                    llRegionSay (g_chan + i, "SWAT!");
                }
                g_rezzed = FALSE;
            }
        }
    }

    object_rez (key id) {
        if (--g_rez_count > 0) {
            llSay (g_chan + g_rez_count - 1,
                   (string)llList2Vector (g_positions, g_rez_count - 1));
        }
    }
    
    touch_start (integer n) {
        if (g_rezzed == TRUE) {
            integer i;
            for (i = 0; i < g_pos_count + 1; i++) {
                llRegionSay (g_chan + i, "SWAT!");
            }
            g_rezzed = FALSE;
        }
    }
}

 

OMG you might be saying 🙂 Let’s take it slow, and go through this. I’ll describe each event handler, so hopefully you can grasp what’s going on.

  • on_rez – we are just restarting the script.
  • changed – we restart the script on a region restart so as to make sure we either rez or derez the butterflies.  We also restart if the inventory changes, which makes it easy to add lines to the notecard for additional butterflies .
  • state_entry – we initialize some variables, find the names of the butterfly objects in our inventory (remember, I said yesterday to name the butterfly objects “butterflys1”, “butterflys2”, and “butterflys3”?).  Then we start reading our notecard, which will transfer control to…
  • dataserver – which gets each line in our notecard, and stores the data in a variable called g_positions, and once we hit the end of the notecard, we start a 30 second timer.  We also derez any existing butterfly objects.
  • timer – here’s where all the work gets done.  Every 30 seconds, we check if the sun is up (indicated by the Z value of the sun’s position).  If the sun is up, and we haven’t rezzed any butterflies yet, rez a randomly selected butterfly object from our inventory 1.5 metres above the rezzer for each of the positions in our notecard.  If the sun is not up, say “SWAT!” to each of our rezzed butterflies on the channel they are listening on to delete them.  Note the last parameter of the llRezObject call.  It tells each butterfly object what channel to listen on (the parameter in the on_rez event of yesterday’s script).  Also note that the rez loop rezzes one additional butterfly object and leaves it above the rezzer.   This makes it easy if you just want one butterfly set.
  • object_rez – here we tell each newly rezzed butterfly object the position it should move to.
  • touch_start – just in case you need to reset everything, you can touch the rezzer to delete any existing butterflies.

We need an optional notecard in the rezzer’s contents called “config”.  It consists of lines containing positions in region co-ordinates where you want additional butterflies to be.  You can also comment out a line by putting a hash in the first column.  So you might have something like this:

# butterflies for woods
<104.3, 10.5, 26.0>
# for skybox
<218.5, 132.5, 2026.0>

After all that we better have a picture 🙂

Here’s a screen shot of the rezzer with the config notecard, the above script, and the butterfly objects in its contents:

Here I’ve made the rezzer white so you can see it, but you should set it to 100% transparent, and phantom too.  You also must call the rezzer “Butterfly rezzer”, because that’s what our script from yesterday is expecting.

And that’s it!  If you’ve followed along with the instructions, 30 seconds after you drop the script in the rezzer, your butterflies should rez!  Assuming the sun is up 🙂  Take the rezzer into your inventory and position where you want one set of butterflies to be.  Add lines to the config notecard for additional ones!  Have fun!


Butterflies, part 1

Butterflies don’t fly at night, have you noticed?  Lots of builders just rez some and leave it at that.  Let’s see if we can get some realism.

I’ll wait while you go and buy some butterflies to play with from this marketplace listing.  They’re only L$10…

Got them?  Good.  Once you unbox them you will see they are copy, modify, no transfer.  This is exactly what we want as we can add scripts to them and rez them to our hearts content.

There are three different types in the box, and we are going to rez them one by one, add a script to them, and take them back into our inventory with a different name so we know which ones are ours.

Here’s the script we are going to add to them:

integer g_chan;

default {

    on_rez (integer chan) {
        g_chan = chan;
        llListen (chan, "Butterfly rezzer", NULL_KEY, "");
    }

    listen (integer chan, string name, key id, string msg) {
        if (chan == g_chan) {
            if (msg == "SWAT!") {
                llDie ();
            } else {
                llSetRegionPos ((vector)msg);
            }
        }
    }
}

Let’s examine what this does.  On rez, we get the integer that our rezzer passed us and listen to the rezzer on that channel.  When we receive a message from the rezzer, we delete ourselves if the message is “SWAT!”, else we interpret the message as a position in region co-ordinates and set our position there.  Pretty straightforward, right?

Create a new script in your inventory (probably in the folder you have the butterflies in) and call it something like “Butterfly listener”.  Then, rez each butterfly object, edit it, and drag the script into it.  Editing these can be a little tricky, so use area search to find and edit them.

Here’s a screen shot showing one set of butterflies rezzed with the new script in them.

Name the butterfly objects “butterflys1”, “butterflys2”, and “butterflys3” either while you’re editing them or when you take them back into your inventory.  Note I’ve chosen to keep the creator’s spelling mistake as this makes them easier to find lol.  Note that all lower case is important!  If you don’t name them exactly this, tomorrow’s script won’t work.  You can see them in my inventory window in the above photo.

Tomorrow, we’ll examine the rezzer script, the control notecard, and how to put it all together.  Say tuned!

 


Boulle

This is fitmesh for Lara, but while my shape is a standard small in classic mesh sizes, I have a few little breakthrough problems with it, which I’m sure I could fix with a few tweaks.  It also comes in standard sizing, and probably a few other fitmesh sizes that I’ve already deleted.

It also comes with a great three texture HUD.  I particularly like this texture but there is a really nice black and white leaf texture too 🙂


Camille

Look what I found hiding in my unopened folder!  If you haven’t figured it out by now, my unopened folders are the messiest part of my inventory.  I regularly go through them trying to clean up the mess by opening things and filing them away, or discarding them.  Life as a blogger lol.

This great looking little belted dress comes in standard mesh sizes and the small fits me perfectly 🙂


Gothic accents

It’s rare I’ve done anything goth related.  I don’t really see myself that way, however, being SL, if you spend enough time here you’ll end up with enough inventory to do literally any style you want.

So I gathered together some goth related items for you today.  And of course I have to go raven haired, light skinned, and put on some black makeup for this!

The skin was a hunt item if I remember correctly, and the lace mask is built right in.

The nails are for Maitreya hands only (they do not work on Slink).  They have a HUD to let you adjust the background color, and set the metal details to either silver or gold.  And the necklace is just a nice piece that would also sit well against a medieval outfit.


ALB Corset Gown

ALB usually makes nice clothing, and this is no exception.  I must say though that I’d be horribly confused as a newbie if I was confronted with the sheer number of items in the contents of this package that was ALB’s hunt item for PoE9.  (And yes, now it’s over, this will be my last PoE post until next Christmas).

It looks lovely.  The texturing particularly on the gown is very nice with the gauze and feathers.

There are 47 pieces of clothing in this package.  There is fitmesh for classic avis, specific fitmesh top and pants for a slew of mesh bodies, fitmesh gloves, sculpts for the fur, and strangely system layer pants and Slink and Maitreya appliers for the same.

Now, I know we love fitmesh, but pants?  This is a gown, surely leave out the 14 different versions of the pants?  And Slink and Maitreya appliers but no Omega?

OK so I figured out what to put on.  I got to the fur trim for the gloves, which are sculpties.  I’m always wary of fur bits anyway, but I put these on and they just looked… weird.  There were these cones running up my arms and clipping my skin… oh do I need to resize to get the cones to go inside my arms?  No, then they poke out the back of my elbows?  What?  I played around for about 5 minutes before I figured out they were 180 degrees rotated.  The cone needed to point down my arms.  A newbie would surely have given up!


Be with you

This skirt and blouse is all on piece standard size fitmesh.  It has a great HUD that allows you to change the textures for the blouse, skirt, belt. and hem.

The mesh detail is really nice, and I have a funny feeling this is going to become a favourite outfit when the weather warms up a little 🙂


Zoe

Let’s have dinner in a nice little New York café, what do you say?

This outfit is the PoE9 Hunt gift from AlaFolie.  It’s a separate top and skirt.  The standard sizes don’t appear to be standard (with things like “XXS XS” on one piece for example) but I didn’t try them on to see as the package contains specific fitmesh for lots of bodies, including Lara.

I also want to specifically mention my hair style.  This is the reds pack for Stone Cold Seduction by Exile.  In my opinion, you won’t find a more versatile hair in SL, and it’s certainly one of my favs.  It’s possible to vary this from dark reds to strawberry blondes like you see here, and you can add streaks in a number of colours.  I just added some brown streaks here to make this appear even more blonde that it really is.