Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Get My Owner's Size

Cherry Hainsworth
Registered User
Join date: 31 Jul 2006
Posts: 125
12-22-2007 20:42
As often promised but never fully addressed, I'm trying to keep all my scripts tidy and my variables CONSISTENT. The only way I'll ever get this project started is by posting chunks from scripts that I'm working on - so here's my first effort.

You will be aware that I'm a lousy programmer with limited knowledge of LSL. So I'll sincerely welcome any suggestions, improvements or comments you choose to offer!

The prim this script goes in:
* Gives its owner's dimensions, but only if it is touched by its owner.

From: someone
// Cherry Hainsworth, December 2007

// VARIABLES USED IN THIS SCRIPT:
// key ownerav; (avatar owner of the scripted prim)
// string ownername; (owner avatar's name)
// vector size; (a size)
// float height = size.z; (size vectors; casting to floats didn't work)
// float widthX = size.x;
// float depthY = size.y;
// string msg1 (etc)

// -------------------------------------------------

// declare globals
key ownerav;
string name;

vector size;

// -------------------------------------------------

default {

state_entry() {
}

touch_start(integer num)
{

// if I was touched by my owner
if (llDetectedKey(0) == llGetOwner())
{

//get their name & dimensions
ownerav = llGetOwner();
size = llGetAgentSize(ownerav);

// tidy up the size data
float height = size.z;
float widthX = size.x;
float depthY = size.y;

// keep it tidy, create the message
string ownername = llKey2Name(ownerav);
string msg1 = ", your height is " + (string)height;
string msg2 = ", your width X is " + (string)widthX;
string msg3 = ", your depth Y is " + (string)depthY;

llSay(0, ownername + msg1 + msg2 + msg3 );

llResetScript();
}

else
// don't reveal my size to strangers!
{ llSay(0, "oops, you're not my owner";);
}
llResetScript();
}
}


(no apologies for misuse of the quote tag!)

QUERY:
I tried various methods to truncate or round down the size vectors - I only need 3 places, max - but kept getting a type mismatch. Any suggestions?

Please let me know if I should continue with this.
Cheers,
Cherry.

***** HAPPY CHRISTMAS, SCRIPTERS! *****
Alicia Sautereau
if (!social) hide;
Join date: 20 Feb 2007
Posts: 3,125
12-22-2007 20:53
bad at coding aswell but

if (llDetectedKey(0) == llGetOwner())

should do the trick aswell i think ;)

edit
using ownerav = llGetOwner() would require a state on_rez() to reset the script if the prim is transferd
it would reset itself after the first click nway but just to complete it :)

feel free to correct me if i`m wrong ;)


reread it and got the idea, must say i like it, wished i could clean my scripts up lol
_____________________
Cherry Hainsworth
Registered User
Join date: 31 Jul 2006
Posts: 125
12-22-2007 21:10
Ah, thanks Alicia!

Too tired to do this now - you're spot on about the DetectedKey thing ... will fix it in the morning.

Christmas? Hurray!! :D