Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

vector, then a string, then a vector again?

Clinton Bulan
Registered User
Join date: 9 Oct 2006
Posts: 22
02-20-2008 15:05
This is probably stupid simple but I haven't slept in 36 hours and my brains fried. I think I might have even had this working once but I can't get it again.

I've got a prim picking up chat from another prim, all it's receiving is that other prims regional location.

I'd like to be able to take that string (originally a vector) and have the listening prim convert it back to a vector for use.

thx!
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-20-2008 15:25
CODE

listen(integer channel, string name, key id, string message)
{
vector pos = (vector)message;
// or...
vector pos2 = llList2Vector(llGetObjectDetails(id, [ OBJECT_POS ]), 0);
...
}
Clinton Bulan
Registered User
Join date: 9 Oct 2006
Posts: 22
02-20-2008 15:49
thanks!

i had a few too many ( )'s floating around
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-20-2008 16:53
just watch out if you ever store a vector as text in a list, you'll want to pull it out as text, THEN convert back to a vector (or put it in correctly to begin with).
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Clinton Bulan
Registered User
Join date: 9 Oct 2006
Posts: 22
02-20-2008 22:52
Thanks for the tip Void. I won't need the list for this application but I'll keep that in mind for later use.
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
02-20-2008 23:16
The whole process used for this is called "Typecasting".

May want to look that up on the LSL wiki or other websites for more information :)
Ollj Oh
Registered User
Join date: 28 Aug 2007
Posts: 522
02-21-2008 00:10
...and the next morning i realized that this reply made no sense.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
02-21-2008 05:12
Does the vector need to be the exact same value when it comes out or is 6 decimal places good enough?

https://wiki.secondlife.com/wiki/Float2Hex
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-21-2008 16:01
might as well ask here... what is the effect of the 'p' in the conversion... in the above function? following the code, it prefixes the exponent, but I wouldn't have thought it'd be interpreted correctly by typecasting what should be a hex value...
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
02-22-2008 20:04
"p" is the base 2 equivalent of "e" in base 10. Essentially it's scientific notation for hexadecimal. LSL is written in C++ and runs on a linux server, LL compiles LSL with GCC which in turn relies upon glibc, glibc was updated to support C99. C99 mandates support for HexFloats. So despite C++ not having support for HexFloats, LL has unwittingly gotten it.

That said, HexFloats are easy to parse and generate. Scientific Notation is difficult to generate and annoying to parse if you want to maintain precision. Mathematically SN requires changing the base from 2 to base 10, HF only requires 2 to 16 which is painless. Looking at floats as binary data, converting the memory representation into a hex float is easy, all the information needed is present in that format. SN on the other had requires complex and unpleasant algorithms.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey