Scripting in Second Life: Part 2 of a Series

By on November 18, 2008

Here are the seven kinds of variables and how you define them (before the default{} area) of the script. Also shown is how to declare variables without values, in case you don’t need a starting value right away.


Integer: A number, positive or negative, with no decimals in it (1,2,3,4, etc).

integer a=5;

integer a;

Float: A number with a decimal and zeroes.

float b=2.434;

float b;

String: A series of letters, numbers and symbols, defined between quotes.

string quote=”4377SgfggA9090$)($*$(AAAA”

string quote;

Vector: a set of 3 floats, usually used to represent 3-D position or movement.

vector jozie=<1.434,53,30>;

vector jozie;

Rotation: a set of four floats, an X,Y,Z and S, which represent an object’s rotation. This set is called a Quaternion. In order to convert an actual rotation to a quaternion, we will use a small snippet of code later.

rotation spinz=<0,0,.42,1>;

rotation spinz;

Key: also known as a UUID, a key is the unique identifier for every single inventory item and rezzed object in SL, from sounds to scripts to avatars. It is defined in quotes but is NOT a string and unless converted to a string with (string) will produce syntax errors when you try to llSay it, etc.

key zooper=”604318a6-88e4-4a05-a128-5bb166e10206″

key zooper;

List: a collection of variables of any kind except lists. Variables are listed inside a pair or brackets and separated with commas. Each entry has its own type so you can mix and match.

list applelist=["hello",-1,4.444,<1.3,4,6>,<-1,.3,0,1>];

list applelist;

Next in our series: the use of functions in scripting. Come back soon!

About

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>