Saturday, January 6, 2007

Scripting


Written 5 December, 2007

Scripting

To make prims and particles “do things,” Second Life uses a scripting language very much like C++.

My experience with C is nonexistent.

I was, however, in the day, a very good BASIC programmer. I could make my little brown Commodore 64 do cartwheels.

My first adventure in SL’s script language was in setting up an object which would reveal my online/offline status. You may have seen these in shops around SL, or at people’s residences.

In fact, it was at Greg’s home that I first thought about getting a online indicator. He and Cade have rural mailboxes set at their property line.

And very nice mailboxes they were, but they had seven prims, and I was being prim-conscious. And I didn’t really want to spend the money.

And so I found a free online status script in my inventory and stuck it in a tiki post I had set at the edge of my property. I reset the script, started it running, and it collected my personal information.

It promptly turned the most hideous shade of blue—and it would be an even more hideous shade of green when I was offline, I knew.

I removed the script from the tiki post, but it remained blue. I looked at the texture. Thank goodness, it hadn’t been ruined (it was a purchased product and I didn’t have the texture), merely given a background color.

I changed the background color from blue to white, and the tiki assumed its usual placid appearance.

But the hover text declaring my online status remained, even though there was no longer any script in the tiki.

Grrr.

And so I mickey-moused it.

I mean, so long as it works, right?

I put the script back in the post and examined it.

The syntax was foreign to me, but I know a variable when I see one.

Unless it varies too much.

Perusing the script, I noticed it repeatedly calling color changes, with three parameters following. Sure enough in some cases, they defined hideous blue, and in some cases, hideous green.

I rezzed a cube and selected edit and then texture. Hmmm. White, it seemed, was 255,255,255. And I’ll just bet black is 0,0,0. I would have done it the other way around, but who am I to complain?

And so I went through the script and in each instance, changed the parameters to 255,255,255.

I missed a couple—as I found out when the tiki still changed color-- but a second and third pass found them. I reset and started the script, it remained an unglamorous but eye-friendly brown.

Hooray! It worked!

I mickey-moused Xubi’s windows in much the same way—although that time I wasn’t altering the actual script, but parameters the windows script called for in the Description field of the windows and window controller. She had to tidy up after me, but I was able to present her with a model that worked.

Does all this make me a scripter? No, certainly not, any more than constructing a pier makes me a builder, but it’s a start.

Methinks it’s time to learn some Cyntax (C syntax).

-----

Photo: Cheyenne Palisades is Online

No comments: