GetPos() and SLURL question
|
|
Nichiren Dinzeo
Registered User
Join date: 14 Feb 2007
Posts: 203
|
06-10-2008 19:00
Using GetPos() of object and logging it in an external db. Have php page that reads this info out of the db and creates an link to http://slurl.com/secondlife/<region>/<x-coordinate>/<y-coordinate>/<z-coordinate>/
problem is, the field in the db looks like <145.04010, 251.01749, 46.07549>
any idea how to write php to create a link using the slurl?
thanks
|
|
Laurence Corleone
Registered User
Join date: 12 Oct 2006
Posts: 126
|
06-10-2008 19:17
Instead of sending the data from llGetPos straight to your data base in one chunk send it in three chunks as var1=location.x var2=location.y and var3=loation.z and then feed those three vars back into the slurl as the three coordinates. Those three vars are "givens" in your lsl after calling llGetPos.
_____________________
There are no stupid questions, just stupid people.
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
06-10-2008 20:01
Either that are you parse it back out when you get ready to use it like this: string x = (string) slurl_vector.x; string y = (string) slurl_vector.y; string z = (string) slurl_vector.z; llOwnerSay("secondlife:///app/teleport/" + region + "/" + x + "/" + y + "/" + 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
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
06-11-2008 00:26
From: Nichiren Dinzeo Using GetPos() of object and logging it in an external db. Have php page that reads this info out of the db and creates an link to http://slurl.com/secondlife/<region>/<x-coordinate>/<y-coordinate>/<z-coordinate>/
problem is, the field in the db looks like <145.04010, 251.01749, 46.07549>
any idea how to write php to create a link using the slurl? Try this (not yet tested; may need minor syntax fixes): $sample = "<145.04010, 251.01749, 46.07549>";
preg_match('/<\s*([0-9]+(?:.[0-9]+)?)\s*,\s*([0-9]+(?:.[0-9]+)?)\s*,\s*([0-9]+(?:.[0-9]+)?)\s*>/', $sample, $matches); $posX = $matches[1]; $posY = $matches[2]; $posZ = $matches[3];
|
|
Nichiren Dinzeo
Registered User
Join date: 14 Feb 2007
Posts: 203
|
06-11-2008 18:32
I would like to do this. Not sure exactly how. like this? vector tblocation = llGetPos(); // and this. vector tbglobalcoord = llGetRegionCorner() + llGetPos(); // and this. integer tbtimestamp = llGetUnixTime(); string tbcoordx = tblocation.x; string tbcoordy = tblocation.y; string tbcoordz = tblocation.z; From: Laurence Corleone Instead of sending the data from llGetPos straight to your data base in one chunk send it in three chunks as var1=location.x var2=location.y and var3=loation.z and then feed those three vars back into the slurl as the three coordinates. Those three vars are "givens" in your lsl after calling llGetPos.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
06-11-2008 20:40
Note that you also get the region name and region-local coordinates in the custom HTTP request headers 'X-SecondLife-Region' and 'X-SecondLife-Local-Position', though you'll have to do very similar parsing to that of the normal vector syntax. See http://www.lslwiki.net/lslwiki/wakka.php?wakka=llHTTPRequest
|
|
Nichiren Dinzeo
Registered User
Join date: 14 Feb 2007
Posts: 203
|
06-12-2008 11:56
the example I give above does not work the location.x fails as a type mismatch. Not sure I am doing this correctly. grrr
|
|
Laurence Corleone
Registered User
Join date: 12 Oct 2006
Posts: 126
|
06-12-2008 12:58
try (string) before location.x like (string)location.x
_____________________
There are no stupid questions, just stupid people.
|
|
Nichiren Dinzeo
Registered User
Join date: 14 Feb 2007
Posts: 203
|
06-13-2008 10:05
From: Laurence Corleone try (string) before location.x like (string)location.x Thanks. That got me closer. this part compiles aok: string tbcoordx = (string)tblocation.x; string tbcoordy = (string)tblocation.y; string tbcoordz = (string)tblocation.z; But it still fails with type mismatch on the "&tbcoordx=" + (string)tbcoordx part below: gMyRequest = llHTTPRequest("http://www.mywebsite/myphp/TBinsert.php", [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], "tbowner="+(string)tbowner+"&tbname="+(string)tbname + "&tbregion="+(string)tbregion + "&tblocation=" + (string)tblocation + "&tbownerKey=" + (string)tbownerKey)+ "&tbcoordx= "+(string)tbcoordx + "&tbcoordy=" + (string)tbcoordy + "&tbcoordz=" + (string)tbcoordz ; } thanks for your help.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
06-13-2008 10:33
From: Nichiren Dinzeo But it still fails with type mismatch on the "&tbcoordx=" + (string)tbcoordx part below:
gMyRequest = llHTTPRequest("http://www.mywebsite/myphp/TBinsert.php", [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], "tbowner="+(string)tbowner+"&tbname="+(string)tbname + "&tbregion="+(string)tbregion + "&tblocation=" + (string)tblocation + "&tbownerKey=" + (string)tbownerKey)+ "&tbcoordx= "+(string)tbcoordx + "&tbcoordy=" + (string)tbcoordy + "&tbcoordz=" + (string)tbcoordz ; Are you sure it is a type mismatch now? You don't have a closing right-parenthesis after the last term in your expression ("  string)tbcoordz ;"  .
|
|
Laurence Corleone
Registered User
Join date: 12 Oct 2006
Posts: 126
|
06-13-2008 10:45
I am doing something similar on a project I have been working on. Without seeing your entire script, all I can do is tell you what is working for me. first I did this - float Locx; float Locy; float Locz; For what I am doing I wanted them rounded so after I called llGetPos() I did - Locx = llRound(location.x); Locy = llRound(location.y); Locz = llRound(location.z); Then in my llHTTPRequest is where I did - "&var1="+(string)Locx+"&var2="+(string)Locy+"&var3="+(string)Locz
_____________________
There are no stupid questions, just stupid people.
|
|
Nichiren Dinzeo
Registered User
Join date: 14 Feb 2007
Posts: 203
|
06-13-2008 10:50
From: Hewee Zetkin Are you sure it is a type mismatch now? You don't have a closing right-parenthesis after the last term in your expression ("  string)tbcoordz ;"  . AHH! geez. I did have the right-parenthesis but I forgot to remove it from the one before it! its working now. your great! thanks
|