Data and Lists

For this week, we were asked to create data, and create a list function. This was done through the use of a list function in code, and then we were meant to add data into it as well as record it.

The easiest thing to do was to record the velocity and name of the person that collided with the object, and so I did just that.

The code is following below…

##############################

list mylist = [];

default
{

state_entry()
{
// llSay(0, “Hello, Avatar!”);

}

collision_start(integer total_number)
{

llOwnerSay(llDetectedName(0) +”::”+ (string)llVecMag(llDetectedVel(0)));

string name = llDetectedName(0);
float vel = llVecMag(llDetectedVel(0));

mylist = [name, vel] + mylist;

}

touch_start(integer total_number)
{
llOwnerSay((string) mylist + ” “);
}
}

##############################

And that’s it. Nothing too complicated, stores data of the avatars that collide with it, and then stores them in the list initialised at the beginning of the code.

The list is then recalled in a long string, as formatting in the chat box is not possible (as far as I know.)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: