Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

vector,s please help

wholesale Bing
Registered User
Join date: 27 Jun 2007
Posts: 24
01-25-2008 17:00
Been trying to get teleport location from a obects name 1am here given up ,
hope from the code you can see the idea ,quite a good chance im doing it totaly wrong













CODE



default
{
state_entry()
{
// string fred= llGetObjectName();
}

touch_start(integer total_number)
{
//vector test=<1.0, 2.0, 3.0>;
vector test= llGetObjectName();// TO OBVIOUS AND EASY TO EVER WORK !


// vector test = fred // thought maybe make object name a string


llOwnerSay((string)test.z); // Outputs 3.0


}
}














[CODE/]
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
01-25-2008 17:11
Er, well, llGetObjectName won't get you the object's position. Hence the name of the function.

What you want to use is a function which gets the object's position; llGetPos is the usual one, if the script is in the object you want to find the position of.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-25-2008 18:32
Typecasting is your friend! Here is a little test script that shows how it works. It is taking the current position and saving it to object name. When you touch the prim it will move 1 meter higher then it was.

CODE

default
{
state_entry()
{
llSetObjectName((string)llGetPos());
}
touch_start(integer total_number)
{
llSetPos((vector)llGetObjectName() + <0,0,1>);
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
wholesale Bing
Registered User
Join date: 27 Jun 2007
Posts: 24
many thanx again
01-26-2008 15:36
cracked it !!! only 4 hrs head scratching this time , would of taken 4 months without your input Jesse

so thank you
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-26-2008 17:20
From: wholesale Bing
cracked it !!! only 4 hrs head scratching this time , would of taken 4 months without your input Jesse

so thank you

Welcome to the wonderful world of scripting. Only gets worse before it starts to sink in and get better. Wish I was joking. Lost umpteen jillion hours of sleep the first couple of months. Extremely frustrating and yet even more rewarding! Made a 50 year old feel pretty good to slowly figure out all of this crap like all the youngins.

Never hesitate to pop in here and ask questions. We don't mind at all.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
wholesale Bing
Registered User
Join date: 27 Jun 2007
Posts: 24
hi stuck again :-)
01-28-2008 14:59
well jesse my brain is pritty old 41 tommorrow ,and half as smart as yours i think :-)

i down loaded lsl editor yesterday what a god send that is

iv got this code to compile and work "eurika ! " i said, but toulk it back to sl and will not complie

setpos returns didgets beyound the dec point ,trying to round them


p.s am on the right track here? is this a example of typecasting? or sigh have i missed the point altogether


CODE


default
{
state_entry()
{
llSetObjectName((string)llGetPos());
}

touch_start(integer total_number)
{
///

vector test=((vector )llGetObjectName() );

integer x = llRound(test.x);
integer y = llRound(test.y);
integer z = llRound(test.z);

llSetObjectName((string)"<"+x+"."+y+"."+z+">"); // problem line compiles and works in lsl editor , dont work in sl


}
}


[code/]
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
01-28-2008 16:30
From: wholesale Bing

llSetObjectName((string)"<"+x+"."+y+"."+z+">";); // problem line compiles and works in lsl editor , dont work in sl


You have to typecast each value individually:

From: someone

llSetObjectName("<"+(string)x+"."+(string)y+"."+(string)z+">";);
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
01-28-2008 18:00
uhm.. wouldn't it be a tad easier this way? or can the x/y/z-values of a vector not be rounded? Can't test this right now, but I thought, since llGetPos() returns a value without too many zeroes, it might work as well?

CODE


test.x = llRound(test.x);
test.y = llRound(test.y);
test.z = llRound(test.z);

llSetObjectName((string)test);



It's not _that_ different - it's just easier to read, I guess (if it works at all :)
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-28-2008 18:16
From: Haruki Watanabe
uhm.. wouldn't it be a tad easier this way? or can the x/y/z-values of a vector not be rounded? Can't test this right now, but I thought, since llGetPos() returns a value without too many zeroes, it might work as well?

CODE


test.x = llRound(test.x);
test.y = llRound(test.y);
test.z = llRound(test.z);

llSetObjectName((string)test);



It's not _that_ different - it's just easier to read, I guess (if it works at all :)

I tried it like this earlier after Yumi's post. Even though it does round each axis up to just an integer, when you typecast it back to a string it will show the zeroes again as in:

<123.0000,123.0000,123.0000>

But the OP's now corrected attempt works:

<123,123,123>

except that Yumi didn't catch the OP's other mistake:

llSetObjectName("<"+(string)x+"."+(string)y+"."+(string)z+">";);

need to replace the two period's with comma's.

llSetObjectName("<"+(string)x+","+(string)y+","+(string)z+">";);
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Krista Chaffe
Registered User
Join date: 16 Jun 2007
Posts: 96
01-29-2008 12:38
Why are you trying to typecast the objectname into a vector ?

Did you mean to get its position maybe ?
wholesale Bing
Registered User
Join date: 27 Jun 2007
Posts: 24
hiya
01-30-2008 16:18
From: Krista Chaffe
Why are you trying to typecast the objectname into a vector ?

Did you mean to get its position maybe ?



using object name and discription as a data store , to answer your question , seems you can,t write to a note card ,