Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

What am I doing wrong here?

Treat Rothschild
Registered User
Join date: 27 Apr 2006
Posts: 20
12-22-2006 19:33
I am scripting a set of curtains, or, if you prefer it in a more manly light "Window Dressings". :D I have two child prims controlled by a master prim. I am trying to make the prim open on being clicked. I'm doing something wrong, because, while I can get all the correct data, when I pass it to the panel in question, it invariably goes to the middle spot of the curtain rod. Another set of eyes would be appreciated.

Treat.

CODE

vector CurrentPos;
vector LocPos;
string VNew;
float Finl=0.2;
float HalfMv;
float MoveIt;
float NewX;


state CheckOpen
{
state_entry(){
LocPos=llGetLocalPos();
vector SizeIt=llGetScale();
MoveIt = (HalfMv-Finl)/2;
NewX = LocPos.x - MoveIt;
string Fakex = (string)NewX;
string fakeit = "<"+ Fakex + ",0.00, 0.00>";
vector NewPos = (vector)fakeit;
getPreciseVector(NewPos, 4);

//llSetPrimitiveParams ([PRIM_SIZE, opened, PRIM_POSITION, (vector)VNew]);
llSetPos((vector)VNew);

llSay (0, "CheckIt");
state default;
}
}
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
12-23-2006 05:29
From: someone
MoveIt = (HalfMv-Finl)/2;


HalfMv has not been given value (probably 0, but really should be initialized).

use llOwnerSay instead of llSay for diagnostics.

eg

llOwnerSay ("SizeIt=" + (string) SizeIt);
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
12-23-2006 07:51
This can't be the whole script. How do you get to the CheckOpen state? What kind of prim are we trying to move here. One gotcha is that prims are moved according to their center. however, some prims are cut in half, so the center is really on the edge, that is, the center doesn't move just because half the prim is invisible.

Lastly, how is "window dressing" manlier than "curtain"? Get a grip. Better yet, write a script that hangs a bed sheet over the window.
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
12-23-2006 12:41
From: Lee Ponzu
Better yet, write a script that hangs a bed sheet over the window.



Or even better, a poster of the Swedish Bikini Team. ;)
_____________________
Champie Jack
Registered User
Join date: 6 Dec 2003
Posts: 1,156
12-23-2006 13:22
From: Lee Ponzu
Lastly, how is "window dressing" manlier than "curtain"? Get a grip. Better yet, write a script that hangs a bed sheet over the window.


This Post made my day. Thanks Lee!

As Lee said, post the "master" script and the "child" script. Also, tell us what kind of prims you are using for the "window dressing". If possible post a picture of your curtains.

I haven't said anything that others didnt say, but I had to thank Lee, so I thought I should say something relevent to the OP.
Treat Rothschild
Registered User
Join date: 27 Apr 2006
Posts: 20
12-23-2006 18:43
From: Lee Ponzu
This can't be the whole script. How do you get to the CheckOpen state? What kind of prim are we trying to move here. One gotcha is that prims are moved according to their center. however, some prims are cut in half, so the center is really on the edge, that is, the center doesn't move just because half the prim is invisible.

Lastly, how is "window dressing" manlier than "curtain"? Get a grip. Better yet, write a script that hangs a bed sheet over the window.

The curtains are simply three pieces. Two rectangular corresponding to the actual window dressings and a curtain rod. The rod is the primary prim that talks to the rectangles through llMessage saying simply "Open" or "Close" There is a piece in there that is not shown that listens for open or close.

I didn't put those in to show because it's self apparent how I'm doing that. At least to me. I am trying to move a child prim to the edge.

Get a grip? I was making a joke, weak as it was. If you have nothing helpful to say, don't say anything.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-24-2006 01:44
From: Treat Rothschild
The curtains are simply three pieces. Two rectangular corresponding to the actual window dressings and a curtain rod. The rod is the primary prim that talks to the rectangles through llMessage saying simply "Open" or "Close" There is a piece in there that is not shown that listens for open or close.

I didn't put those in to show because it's self apparent how I'm doing that. At least to me. I am trying to move a child prim to the edge.

Get a grip? I was making a joke, weak as it was. If you have nothing helpful to say, don't say anything.



The Source for getPreciseVector is missing and could quite possibly be the cause of the problem.

I think Lee was replying to your joke with a further Joke., As in 'Real Men' dont do curtains...
Treat Rothschild
Registered User
Join date: 27 Apr 2006
Posts: 20
12-24-2006 18:27
From: Newgate Ludd
The Source for getPreciseVector is missing and could quite possibly be the cause of the problem.

I think Lee was replying to your joke with a further Joke., As in 'Real Men' dont do curtains...


Thank you. I'll check that out.

Lee, I apologize for my outburst. Merry Christmas. :)
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
yet another joke...
12-25-2006 09:19
From: Treat Rothschild
Thank you. I'll check that out.

Lee, I apologize for my outburst. Merry Christmas. :)

I'm an athiest.
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
12-25-2006 09:25
You do a llSetPos(VNew), but I don't see VNew anywhere. Maybe I missed it.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-25-2006 13:48
OK, Newgy was bored on Christmas Day.

Relooked at the OP and I'm even more intrigued.
As Lee pointed out VNew is never calculated, but my question is why the following 3 lines :-

CODE

string Fakex = (string)NewX;
string fakeit = "<"+ Fakex + ",0.00, 0.00>";
vector NewPos = (vector)fakeit;

instead of
CODE
vector NewPos = < NewX , 0.0 , 0.0 >;
Treat Rothschild
Registered User
Join date: 27 Apr 2006
Posts: 20
12-25-2006 19:50
All right, here it is with the getPreciseVector function that I got off this forum. All it does is basically bring it down to two decimal places. It needs to be worked on and I wasn't absolutely sold on using it.

Treat

CODE
vector CurrentPos;
vector LocPos;
string VNew;
float Finl=0.2;
float HalfMv=0.0;
float MoveIt=0.0;
float NewX=0.0;

string getPreciseVector(vector V, integer precision) {
string VX = (string)V.x;
string VY = (string)V.y;
string VZ = (string)V.z;
VX = llGetSubString(VX,0,precision);
VY = llGetSubString(VY,0,precision);
VZ = llGetSubString(VZ,0,precision);
string VNew = "<"+VX+","+VY+","+VZ+">";
llSay (0, "Vnew is "+ VNew);
return VNew;
}// getPreciseVector()


state CheckOpen
{
state_entry(){
LocPos=llGetLocalPos();
vector SizeIt=llGetScale();
HalfMv = SizeIt.x/2;
MoveIt = (HalfMv-Finl)/2;
NewX = LocPos.x - MoveIt;
string Fakex = (string)NewX;
string fakeit = "<"+ Fakex + ",0.00, 0.00>";
vector NewPos = (vector)fakeit;
getPreciseVector(NewPos, 4);

llSetPos((vector)VNew);

state default;
}
}
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-26-2006 02:09
From: Treat Rothschild
All right, here it is with the getPreciseVector function that I got off this forum. All it does is basically bring it down to two decimal places. It needs to be worked on and I wasn't absolutely sold on using it.



Ah so it should really be GetImpreciseVector then......

2 decimal Places isnt exactly precise positioning.
It is also an awful lot of truely redundant, as in not required, code.

Its alwasy useful to post as much of your code as you can, it helps us all get a better understanding of how your script works.
Treat Rothschild
Registered User
Join date: 27 Apr 2006
Posts: 20
12-26-2006 04:12
From: Newgate Ludd
Ah so it should really be GetImpreciseVector then......

2 decimal Places isnt exactly precise positioning.
It is also an awful lot of truely redundant, as in not required, code.

Its alwasy useful to post as much of your code as you can, it helps us all get a better understanding of how your script works.
*chuckles* Point made. Passing more than two decimal places makes llSetPosition and llSetPrimitiveParams fail. getPreciseVector is a workaround for that. I'll find another method.

I'll tighten up the code. I still have the problem of it moving to the center, though.
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
12-26-2006 06:04
From: Treat Rothschild
Passing more than two decimal places makes llSetPosition and llSetPrimitiveParams fail. .

I don't understand this. llSetPos and its equivalent in llSetPrimitiveParams take float parameters. All you are doing with your cutting of decimal places is introducing an offset error. You are always rounding down, not going to the nearest digit! Floats are innately accurate to at least 7 decimal digits. The place of the decimal point has very little to do with it.

hth

ed
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-26-2006 06:04
I've never had a problem with decimal places.