Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Capturing part of Coordinates - Scripting help

Dragon Muir
Registered User
Join date: 25 Jun 2005
Posts: 60
06-04-2007 22:16
Since most of the scripting language is difficult for me to understand even when I do try to find the answers, I thought I might as well ask on the forums in the hopes someone might help me a little.

I can not stress this enough, it must be basic. Like mind numbing basic, so I can play with it and learn how it works. I am not a completely new. I am able to look at a basic scripts and if it is fairly simple, figure out how to manipulate it.

I have been playing with a teleporting script, which is a lot of fun, but beyond my ability to easily alter and manipulate, but what I want to do is probably simple. You have a <X,Y,Z> location you want to teleport. You enter that in the script, sit, and boom! You are there.

I want to capture the X and Y coordinates of my Avatar and plug that in. I want the Z coordinates to remain constant. Is their a simple function I can use to capture those two coordinates so I can plug that into complete coordinate?

Example:

X = FUNCTION CAPRURE X
Y = FUNCTION CAPTURE Y

LOCATION = <X, Y, 500>


I know it isn’t that easy, but I think I could understand a coded example. Thank you to whomever replies to my post. It is fun to learn how scripts work and how to make them do what you want. ^..^

PS: Sorry if I use any wrong terms. : x
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
06-05-2007 00:04
default
{
touch_start (integer num_detected)
{
llRegionSay(998,(string)llGetPos());
}
}

put that in a small, flat prim.. place in the location where you want to "record" a position

in your script.. place this..

integer channel = 998;
vector location;
default
{
state_entry()
{
llListen( channel, "", NULL_KEY, "" );

}

listen(integer channel, string name, key id, string message)
{
location = (vector)message;
}

}

you can then set the first prim at the location you wish to tell the other script, in the 2nd script, when you touch the first, the xyz vector location is stored in the vector variable "location". I think that's what you need, hope it helps.
Dragon Muir
Registered User
Join date: 25 Jun 2005
Posts: 60
06-05-2007 00:40
I think I understand what this script does and what your trying to do. It simply records a <x,y,z> location and then tells the teleport script. Thank you for trying to help, but this isn’t what I mean. Sorry if my explanation is confusing.

I will just explain “exactly” what I am expecting to use it for.

I already have the means to rez an object by voice command. That object will be a long distance sit teleport prim. The prim will be temp on rez so will disappear in a short period of time. I want to teleportor to teleport you vertically 600m up. The X and Z part of the complete coordinates will have to be the razzed objects current location, so I need to somehow serrate the string llGetPos() gives you.

[ I think that sort of output is called a string..? ]

Thank you Johan Laurasia for trying to help. : )
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
06-05-2007 00:48
Not sure what you are trying to do, and if you want a simple sit teleporter, using the sit position only, you can't go 600M, it's limited to 300m.

However, I think what you want is to get the coordinate of the x in the vector <x, y, z>?

This is done for example:

vector pos = llGetPos();

float X_POSITION = pos.x;
float Y_POSITION = pos.y;
float Z_POSITION = pos.z;

if that is what you want, you need to put a . (or period) after your vector variable to obtain the x, y, or z. What this does is tell the compiler Look inside this variable pos and give me the value of the variable called x.

This will also work in reverse.

pos.x = 300;
pos.y = 300;
pos.z = 300;

now vector pos is now <300, 300, 300>

I hope this is what you were looking for :)
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
06-05-2007 00:50
llGetPos actually retuns a vector (xyz) not a string which makes life ezier

you can spererate vectors into floats

lets say you have vector bob = <1.0,2.0,3.0>;

and you only need the y value

well you can do something like

float jim = bob.y;

bob.x would come out as float 1.0
bob.y would come out as float 2.0
and bob.z would come out as float 3.0

then you can typecast format transfer add subtract or whatever else you want to do
Dragon Muir
Registered User
Join date: 25 Jun 2005
Posts: 60
06-05-2007 02:12
Wow. It was a lot simpler then I thought it might be. I understand now! Thank you Lazink Maeterlinck and Osgeld Barmy for your help. The script does exactly what I wanted now.

^..^

PS: I don’t suppose any of you or anyone know of any mentoring type groups for scripting? I try to figure out how do what I want with my limited understanding and using online SL wiki, but even after reading what I look up it can sometimes be a little confusing. Not that I ever plan to do anything extravagant. Just be nice to have someone or a group of people in SL I could occasionally ask questions just like this for simple clarification. I wouldn’t want to abuse anyone’s help by asking them to make me scripts. I want to make it myself. If anyone wouldn’t mind me bugging them once in a great while about simple scripting clarification I would really appreciate it. I don’t have any scripting friends. :D
Ed Gobo
ed44's alt
Join date: 20 Jun 2006
Posts: 220
06-05-2007 06:19
From: Lazink Maeterlinck
Not sure what you are trying to do, and if you want a simple sit teleporter, using the sit position only, you can't go 600M, it's limited to 300m.

It is limited to 300 m in any of x, y or z direction. However, if you think of a 300 M edged cube, the distance from one corner to its most distant opposite corner is a lot further than 300. I found 500 M unreliable, but 400 M works fine. If you make the tp from an orb, it won't be so obvious that it is tilted on two axes.
Lyn Mimistrobell
(waiting)
Join date: 11 Jan 2007
Posts: 179
06-05-2007 11:32
I suggest you check the wiki (http://rpgstats.com/wiki/index.php?title=Main_Page). On the homepage you'll find information about mentors, groups and teachers.
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
06-05-2007 20:27
thats not the wiki

the new offical wiki is @ http://wiki.secondlife.com/wiki/LSL_Portal

the old offical wiki is @ http://www.lslwiki.net