These forums are CLOSED. Please visit the new forums HERE
vector |
|
Alberto McGettigan
Registered User
Join date: 14 Jun 2005
Posts: 57
|
08-28-2005 13:07
Trying to pass a vector variable from one object to another thru RezObject but cant seem to pass anything but a integer can someone help.
|
Aliasi Stonebender
Return of Catbread
![]() Join date: 30 Jan 2005
Posts: 1,858
|
08-28-2005 13:41
Trying to pass a vector variable from one object to another thru RezObject but cant seem to pass anything but a integer can someone help. Simple. You can't pass anything BUT an integer. So, how do you get around this? Well, you can either devise some system to encode the vector into an integer and pass it, or you can use the integer to specify a channel for the receiving object to listen to, and pass the vector on as a string. _____________________
Red Mary says, softly, “How a man grows aggressive when his enemy displays propriety. He thinks: I will use this good behavior to enforce my advantage over her. Is it any wonder people hold good behavior in such disregard?”
Anything Surplus Home to the "Nuke the Crap Out of..." series of games and other stuff |
Douglas Callahan
Fresh Prince Of SL
![]() Join date: 2 Jul 2004
Posts: 349
|
08-28-2005 16:11
I'm not sure if this would work, but I would certainly try it before opening an on_rez listen:
Convert the vector to an integer like so: CODE vector vec = <1,2,3>; This sends the integer as the objects start_params, which can be gotten by llGetStartParams(); Then use a reverse method like so: CODE integer xcoord = (integer) llGetSubString((string) llGetStartParams(),0,0); Not sure if this will work but its worth a try. Just gotta think outside the box sometimes, especially to avoid listens or other lag causing functions _____________________
Other than that, Mrs. Lincoln, how was the play?
|
Aliasi Stonebender
Return of Catbread
![]() Join date: 30 Jan 2005
Posts: 1,858
|
08-28-2005 17:04
I'm not sure if this would work, but I would certainly try it before opening an on_rez listen: Convert the vector to an integer like so: *snip* Not sure if this will work but its worth a try. Just gotta think outside the box sometimes, especially to avoid listens or other lag causing functions Actually, Doug, that's somethign I've considered. main problem is, it won't work for all possible vectors. _____________________
Red Mary says, softly, “How a man grows aggressive when his enemy displays propriety. He thinks: I will use this good behavior to enforce my advantage over her. Is it any wonder people hold good behavior in such disregard?”
Anything Surplus Home to the "Nuke the Crap Out of..." series of games and other stuff |
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-28-2005 17:30
You're quite right Aliasi, it won't work for all vectors, in fact it's pretty much impossible to do for all vectors.
But you could do something with coding to give you 3 sig figs on any vector with a bit of thought which is less than perfect for positions say, but probably close enough for any other application. |
Aliasi Stonebender
Return of Catbread
![]() Join date: 30 Jan 2005
Posts: 1,858
|
08-28-2005 17:39
You're quite right Aliasi, it won't work for all vectors, in fact it's pretty much impossible to do for all vectors. But you could do something with coding to give you 3 sig figs on any vector with a bit of thought which is less than perfect for positions say, but probably close enough for any other application. True enough! _____________________
Red Mary says, softly, “How a man grows aggressive when his enemy displays propriety. He thinks: I will use this good behavior to enforce my advantage over her. Is it any wonder people hold good behavior in such disregard?”
Anything Surplus Home to the "Nuke the Crap Out of..." series of games and other stuff |
Masakazu Kojima
ケロ
![]() Join date: 23 Apr 2004
Posts: 232
|
08-28-2005 18:07
CODE integer pack_vector(vector v) { This gives you 0-255 x, 0-255 y, and 0-65535 z, which is perfect for sim coordinates if you don't need fractional portions. Another trick you could do is to rez the object with it's up (or any) axis pointing towards the vector you want, and use the integer parameter as a distance, then just multiply llRot2Up(llGetRot()) * param. You can multiply/divide it by 10s to get decimal precision. I might put together an example later. |
a lost user
Join date: ?
Posts: ?
|
08-28-2005 23:28
hrmm yes.. all these things are good.. yes but why bother?
In object being rezzed: CODE
Do anything else you want, even do normal listens, just don't use the same channel as you are using for the on_rez listen. The llRezObject script would be something like: CODE
You still going to need a script in both objects anyway, don't see why everything needs to be all complicated, especially when you can't rez further than 10m from the object doing the rezzing. If you were able to spawn/rez objects in other sims and so on, I could see a point to sending variant data through the integer param. |
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-29-2005 01:58
I'm not 100% sure, but I suspect if you remove the listen *before* processing the message you lose the message content. Certainly for sensors if you remove them you destroy all the llDetected* content.
But yes, you're right it is almost certainly more elegant to do it the listen way, but we were specifically asked for ways to pass a vector in the integer of the llRezObject() function. Reasons for doing it that way who knows. Actually your code could be made safer for multi rez objects too. You use p as the listen channel. IIRC any non-zero integer evaluates as true. |
a lost user
Join date: ?
Posts: ?
|
08-29-2005 04:04
Yah you can remove the listen immediately.
CODE
That at least is my understand of how the system works. I could be wrong of course. And yes, any non-zero value is fine, although I think it must be a positive value but ofcourse you could simply change it to: if(p != 0) or whatever you needed. I wouldn't call using a listen event that is immediately removed once the information is received, "elegant".. just easier to comprehend. |