Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Vector values to llMessageLinked

Arrekusu Muromachi
SL Fighter Ace
Join date: 20 Feb 2005
Posts: 32
04-30-2006 20:25
This may sould noobish but is there any way to convert vector values into something that llMessagedLinked can use and then convert them back? I'm trying to make the color changer on my planes efficent by using one script as a listen master and sending the color values through link_message.
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
04-30-2006 20:31
From: Arrekusu Muromachi
... is there any way to convert vector values into something that llMessagedLinked can use and then convert them back?


llMessageLinked (.... (string)MyVector);

vector MyVector = (vector) Message;
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
04-30-2006 20:35
There's sample of serialization routines on LSL Wiki, which basically convert lists to strings and back, while preserving actual data types.

For better accuracy, there's also Float2Hex library which can be used to convert individual float values of vector into strings, then passing them around and assembling back on arrival, either with combination of the above, or on its own ^^;;

edit: scratch that, for passing colour values around it's probably more useful to convert the vector components into integers in 0-255 range, then pass them together o.O

edit2: after some checking not really worth the trouble... the earlier suggestion with plain casting works well enough, too.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
05-01-2006 10:20
Hex2Float is overkill in this case, Hex2Float, is really only useful when you want to make sure the float, vector or rotation are transmitted perfectly, colors on the other hand can be accurately represented with 6 decimal places. Rotations rarely transmit perfectly. Hex2Float would work best in XyCalc, where you don't want to add extra dataloss into the calculations. In most situations good enough, is good enough, but for those situations where perfect is needed there is Hex2Float.
_____________________
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
Adriana Caligari
Registered User
Join date: 21 Apr 2005
Posts: 458
05-01-2006 10:52
In the sending script

CODE


vector test = <1.23,4.56,7.89>;
llMessageLinked( LINK_SET,0,"vector=" + (string)test,NULL_KEY );



then in the receiving script

CODE

link_message( integer set, integer to, string mess, key id )
{
list temp = llParseString2List( mess,["="],[] );
string comm = llList2String( temp,0 ) ;
string parm = llList2String( temp,1 );
//
// blah blah
//
vector received_vector = (vector)parm;
//
// do something with the vector
//
}




The list is overkill - but I like to pass comm and parm at the same time so I sorta know what I am getting ( and it is an example of sending variable=value etc )

[edit]
Oops sorry angela didn't see your post
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
05-01-2006 11:15
From: Strife Onizuka
Hex2Float is overkill in this case (..)

Aye, i sort of missed the part it'd be used for passing colour values, on initial read >.<
Arrekusu Muromachi
SL Fighter Ace
Join date: 20 Feb 2005
Posts: 32
05-03-2006 20:59
If I can figure out the complex script that I already have I'll go ahead and try the things ya all gave me. Thanks! n.n