Name: Scale

Image:

Scale your weight on Earth

Description: Touch this scale and it will say your weight and mass in the chat window.

Creator: Patio Plasma, 1 December 2008

Location: http://slurl.com/secondlife/Sim/180/47/26/

Graphics: "Your Weight, Touch"  is displayed as Floating text
Here is the LSL command

llSetText("Your Weight,\n Touch", <1,1,0>, 1.0);

The \n is a line feed, the vector <1,1,0> is a color vector red plus green = yellow, 1 is the transparency 1 = opaque.

Lessons:

There are two scripts in the scale, one dislays the floating text.(see above)

default
{
state_entry()
{
llSetText("Your Weight,\n Touch", <1,1,0>, 1.0);
}
}

The second script says your weight

It starts with a user defined function es_round( number, precision) which receives two inputs a number and the precision which isthe number of decimal points

It outputs a string which is the number rounded to the selected number of decimal points.

The important function is
float avmass = llGetObjectMass( llDetectedKey(0));

This gets the objects mass of the object specified by its key number, here it is the number of the avatar that touched the prim.

The mass is in Lindograms, avatars have a mass usually under 2.0 Lindograms which depends on the size of the avatar. The program converts lindograms to kilograms and pounds.

// Your Avatars weight on Earth touch to activate scale. by Patio Plasma.


// Round off function by Emileigh Starbrook

integer precision=2;

string es_round(float num, integer precision)
{
list tmp=llParseString2List((string) num, ["."],[]);
string major=llList2String(tmp,0);

float pow=llPow(10,precision);

float minor=(float) ("0." + llList2String(tmp,1));
integer iMinor=llRound(minor * pow);

return(major + "." + llGetSubString((string) iMinor,0,precision-1));
}

default
{

touch(integer n)
{
float avmass = llGetObjectMass( llDetectedKey(0));
float avmassk = avmass * 41.39;
string roundavmass = es_round(avmassk,precision);


llSay(0, llDetectedName(0) + " your mass is " + (string)roundavmass + " kilograms."); // the first parameter , 0, is the channel that the following string will be said on.

float avmassp = avmass * 91.05;
roundavmass = es_round(avmassp,precision);


llSay(0, llDetectedName(0) + " your weight is " + (string)roundavmass + " pounds."); // llDetectedName(0) is the name of the avatar who touched the prim.
}
}

Comments:

Many Real World museums have an exhibit "Your Weight on other worlds" where you stand on a scale that reads out your weight on Jupiter.

In the same way this exhibit tells you your avatars weight on Earth.

Notice that avatars tend to be much taller than real life people, so don't be surprised if your 2 meter tall avatar,( six foot six inches), weighs a lot.

 

Patio Plasma

Copyright 2007

Updated 28 May 2007