Jump to content

Region to Global coordinates


money Crannock
 Share

You are about to reply to a thread that has been inactive for 4724 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

region coodinate ARE global coordinate, unless you mean gridwide coordinates (as can be use by llMapDestination)

in which case you add the region coordinates to llGetRegionCorner.

 

yeah the language used overlaps a bit, that's why I asked

Link to comment
Share on other sites

basically, I want to make a teleporter using rlv, which uses @tpto:x/y/z=force (or something along those lines), however their in global coordinates, so lets say i wanted to go to laval island at <40,40,2000>, i would need to convert it for the rlv function. I did find an example script online here: http://wiki.secondlife.com/wiki/LSL_Protocol/RestrainedLoveAPI but it lags a few seconds before teleporting.

Link to comment
Share on other sites

Marine's example shows you the method, though.  

You get the global (i.e.. position on the grid) coordinates of the sim with llRequestSimulatorData("sim name",[DATA_SIM_POS]).   When the dataserver replies, it gives you the position on the grid of the Sim's SW corner.   You break down the reply in exactly the way she does it there, into the x, y and z coordinates, and then add to those, the coordinates on the sim you need -- in your example, <40.0,40.0,2000.0>, as she does in that example, and turn them into a string for the teleporter to say.

Any lag is almost certainly caused by the delay in the dataserver responding and the script processing all this.   But you can avoid that, since you know your destination(s) beforehand, by using the method Marine demonstrates there to build a list of the coordinates in which you're interested when the script first starts running.   The sims aren't going to move, after all, so there's absolutely no need to recalculate the target position every time you use the device.

Then when I come along and set off your teleporter, the thing knows what it's supposed to say, and the only delay in teleporting me is going to be if my relay is set to ask me before accepting commands from strange objects and I take a few seconds to agree.

 

Link to comment
Share on other sites


money Crannock wrote:

Thanks for the explination, the problem is that I was using <40,40,2000> as an example, the position changes everytime its used though, so it will lag. I guess if there's no way to get around it, I'l try another way of doing it.

I'm afraid that if you need to find the sim's grid location, the only way to do it -- at least the only way I know -- is to call llRequestSimulatorData.   You could trying storing the coordinates -- or, rather, the string @tpto is to use -- for specific locations when you look them up, I guess, and then, when you tell it you want to go somewhere, first have the script look in the list to see if it's a location it already knows.    If it is, then use the appropriate string, and if not, ask the dataserver where to go.

My Dari's Haus collar stores locations I use frequently, and I never seem to need more than 10 or so.   That might be an idea to explore.

Link to comment
Share on other sites


Void Singer wrote:

I seem to be confused.... what's wrong with llGetRegionCorner?

Nothing, so long as you're in the region in whose coordinates you're interested  when you call it.    But the OP wants, I think, to calculate the target coordinates at run-time and can't rely on being in the same region as the target when it's necessary to do the calculation.

Link to comment
Share on other sites

ah, ok, that makes sense, I missed that...

yeah unfortunately there may be a slight lapse between requesting data for another region and actually getting, if it's the region you are in though, it tends to be near instant (but then they could have used the other function which is instant). as noted the only work around is to request it in advance and store it.

Link to comment
Share on other sites

Maybe an example will help.   

 

vector sim_pos;vector local_pos;vector target_pos;string to_say;default{    state_entry()    {       sim_pos = llGetRegionCorner();  // grid co-ordinates of the SW corner of the sim I'm on        llOwnerSay((string)sim_pos);       local_pos = <148.0,42.0,22.0>;  // target position on the sim -- change this, unless you're i) on the Freedonia sim and ii) want to visit my shop       target_pos = sim_pos+local_pos;       to_say = (string)((integer)target_pos.x)+"/"+(string)((integer)target_pos.y)+"/"+(string)((integer)target_pos.z);       llOwnerSay(to_say);    }    touch_start(integer total_number)    {        //whoosh!        llOwnerSay("@tpto:"+to_say+"=force");  //only works if the owner uses rlv, obviously    }}

 Note, though, that I could use this to get the global coordinates of my shop and then use them anywhere on the grid.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4724 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...