Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Trying to determine a vector... HELP!

Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
11-10-2004 18:33
I am using some code I found in the scripting library.... this is very strange to me...

CODE

//Selective Teleporter.
//Based on scripts by Nick Fortune, and concepts from a free teleport script.
//This script is FREE to all who wish to use it. No profit is to be made from this script.
//Please leave this heading intact.

//The list read in / read out is from an example provided by Christopher Omega.

//This script will provide teleport as a pie menu option for those who are on the access list and touching the object. The access list can be updated by touching the object that the script is on and saying the command words. When object is ready to listen to you it will display "Listening..." in floating text above it. The object listens for 20 seconds of silence before it shuts off its listen to help with lag.

//commands
//Add a name to the access list: tele_add::Avatar Name
//Remove a name from access list: tele_rem::Number Associated with Avatar in list.
//View the access list: tele_list

string Detected;
list Allowed_avs; //People who are allowed access
integer Listen_Flag = -1;

hearing() {
if(Listen_Flag != -1)
llListenRemove(Listen_Flag);
Listen_Flag = llListen(0,"",llGetOwner(),"");
llSetText("Listening...",<1,1,1>,0.8);
}

list_out() {
string toSay = "";
integer i = 0;
integer len = llGetListLength(Allowed_avs);

llWhisper(0, "/me Access List:");
for (i = 0; i < len; i++) {
string element = llList2String(Allowed_avs, i);

toSay += (string)i;
toSay += ": ";
toSay += element;
toSay += " ";
}
llWhisper(0, "/me "+toSay);
}

no_access() {
llSetSitText("Sit Here");
llSitTarget(<0,0,0>, ZERO_ROTATION);
llSetColor(<1,0,0>, ALL_SIDES);
}

access() {
llSetColor(<0,1,0>, ALL_SIDES);
llSetSitText("Teleport");
llSitTarget(<0,0,300>, ZERO_ROTATION); //<----replace vector with your target vector.
}

default {
state_entry() {
llVolumeDetect(TRUE);
llWhisper(0, "Selective Teleporter Active");
}

touch_start(integer num_touched) {
if (llDetectedKey(0) == llGetOwner()) {
hearing();
}
else {
llWhisper(0, "You are not authorized to perform this action");
}
}

listen(integer chan, string name, key id, string msg) {
llSetTimerEvent(20);
list params = llParseString2List(msg,["::"],[]);
string cmd = llList2String(params,0);

if (llToUpper(cmd) == "TELE_ADD") {
string name = llList2String(params, 1);
Allowed_avs += name;
llWhisper(0, "/me has added: "+name);
}
else if (llToUpper(cmd) == "TELE_REM") {
integer index = (integer)llList2String(params, 1);
string name = llList2String(Allowed_avs, index);
Allowed_avs = llDeleteSubList(Allowed_avs, index, index);
llWhisper(0, "/me has removed: "+(string)index+": "+name);
}
else if (llToUpper(cmd) == "TELE_LIST") {
list_out();
}
}

timer() {
llSetTimerEvent(0);
llListenRemove(Listen_Flag);
llSetText("",<1,1,1>,0.8);
}

collision_start(integer total_number){
integer i;
for(i=0; i<total_number; i++) {
Detected = llDetectedName(i);
if(llDetectedType(i) & AGENT) {
if(llListFindList(Allowed_avs,[Detected]) == -1) {
// Not on the list.
no_access();
}

else{
//On the list.
access();
}
}
}
}

changed(integer change) {
if (CHANGED_LINK) {
key avatar = llAvatarOnSitTarget();
if (avatar != NULL_KEY) { //Make sure there is an Avatar here.
llUnSit(avatar);
llPushObject(avatar, <0,0,10>,ZERO_VECTOR, FALSE);
no_access();
llSetColor(<0,0,0>, ALL_SIDES);
}
}
}

collision_end(integer total_number) {
no_access();
llSetColor(<0,0,0>, ALL_SIDES);
}
}


Ok... the chunk of this code that needs to be modified for this to work is:
llSitTarget(<0,0,300>, ZERO_ROTATION); //<----replace vector with your target vector.

this is found in the access function.

I was able to use this code in 1.5.6 (prior to 1.5.7). From the ground in my house, I was able to make the proper change to get to my house in the sky. The house in the sky is about 300m up, and a couple meters south and east of where the teleporter is.

I came up with:
llSitTarget(<-18.601,8.836,266.978>, ZERO_ROTATION);

and that works, at least marginally. That takes me from:
60.601
213.164
33.022

to:

42
222
300

No problem.

Certainly if I want to go down, I have my own "Go Home" teleporter, and while that's fine for me, I want to permit others on my list to also be able to get back down in a decent manner.

I wanted to put the teleporter in the corner of the room of my workplace so that it's out of the way. So, now I am up around 300m in the sky and want to get back down. I would at that point be located:

41
222
300.5

and want to go to:

62
212
33

and it seems like (at least what I did to make the original work) the proper vector would be:

llSitTarget(<21,-10,-267.5>, ZERO_ROTATION);

and that should bring me home again.... but NOOO...

I KNOW this code works because I am using the same code to go UP to the shack in the sky. Can someone shed a little light on my problem here, or offer me another script. Vector math is really hurtin my head! hahaha

Thanks in advance for someones' help! I do NOT know why this is kickin my butt!
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
Color me NOOB! hahaha
11-10-2004 22:14
If I caused anyone any brain stress... I am so sorry. Let this be a lesson to me...

There were some things I left out.

Yes I have already discovered my "attack of the dumbass".

The SCRIPTING was fine. Woulda, shoulda, COULDA worked...

In my infinite wisdom I decided to make the teleport prim a SPHERE. Well, in one of the many iterations of editing, moving and bla bla while I was learning and trying to make this thing work I shifted the axis of the sphere... so that the Z axis was pointing out to the side.

What I should have noticed was that I was about 300m laterally from where I wanted to be, rather than 300m in elevation, I was 300m in longitude!

At some point in my editing, I turned the prim on it's side so the Z axis was NOW horizontal. One of the keys to the troubleshooting of what I thought was a scripting problem was that I decided to set two of the parameters to zero and the Z parameter to 3 so I could watch my movement.

I did not connect the difference in the movement until a friend mentioned that they get their coordinates from the "xyz" that was when I realized I might have jostled the axis with an inadvertant axis shift.

Once I looked at the facts I wanted to kick myself... Any way I am just trying to say here that this is something you should look for. (I'm still learning! hehe)
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Moleculor Satyr
Fireflies!
Join date: 5 Jan 2004
Posts: 2,650
11-11-2004 00:05
Yeah, the default rotation of the sphere is one of my longest standing bug reports with the Lindens. I noticed it with exactly the same situation you're in. (Though it did end up making me figure out how to negate rotations of any kind.)
_____________________
</sarcasm>
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
11-12-2004 12:21
Oh yeah, I was really digging hard to figure why one would work and the other not, and was trying to think up all kinds of things to troubleshoot it... of course none worked... then came the magic word that someone said (I don't even remember what it was... ) I changed the sphere to a cyl... and that did it for me. Any idea if changing the XYZ to the Global might have also worked? (or if it was global to local?)

I'll have to try that later.
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Water Rogers
Registered User
Join date: 1 May 2003
Posts: 286
11-12-2004 14:08
yeah, a good trick to working with objects and scripts that depend on the local axis (like vehicles or sit_target) is hit the "Show local Axis" radio button in the editing menu. Makes life and troubleshooting a bit easier. You'll notice with a bit of testing that if you set a sit-target at a certain position, sit on it and look at how you're positioned. Then rotate the object 90 degrees, hop off... then sit back on it, you'll be sitting at the same position of the objects local axis -- just rotated around.

-_Water
_____________________
From: Philip Linden

For the more technically minded - the problem is actually NOT the asset server (or 'asshat' as you prefer to affectionately call it herein).