Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Path Cut

SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
08-11-2009 08:16
I have a bread box that I would like to open and close by clicking on it and I'm not sure how to go about building a script for it. Is it possible to script in a path cut so that it starts at a certain value ends at a certain value and checks to see what value it is at and goes to the oposite value everytime its clicked?
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
08-11-2009 08:55
You can use path cut. To read it use: http://wiki.secondlife.com/wiki/LlGetPrimitiveParams

You probably could also use a door script.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
08-11-2009 10:03
Or script the lid to go from llSetAlpha(1.0, ALL_SIDES) to llSetAlpha(0.0,ALL_SIDES) or vice versa in a touch_start event. That should work if you only need to see in the box and don't need to touch something in it.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
08-11-2009 12:37
I'll warn that if you want to do path cut in stages (like a roll away effect) then it's going to be choppy. if you go for a single stage swap then you can get away with a simple switch such as

gBooOpen;

(gBooOpen = !gBooOpen * percentage)

which will shuffle between 0.0 and your percentage...

or

(gBooOpen = !gBooOpen + percentage)

which will shuffle between percentage and percentage + 1.0, which I *think* the percentage over 1 will default to 1
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
08-13-2009 05:31
Could someone look at this and let me know what I'm doing wrong?

default
{
state_entry()
{
llSay(0, "Hello, Avatar!";);
}

touch_start(integer total_number)
{

if (vector cut == < .75, 1, 0.0 >;)

{
llSetPrimitiveParams([PRIM_TYPE,
PRIM_TYPE_CYLINDER,
PRIM_HOLE_DEFAULT, // hole_shape
< 0, 1, 0.0 >, // cut
0.95, // hollow
< 0.0, 0.0, 0.0 >, // twist
< 1.0, 1.0, 0.0 >, // top_size
< 0.0, 0.0, 0.0 > // top_Shear
}

else if ((vector cut == < 0, 1, 0.0 >;)
{

llSetPrimitiveParams([PRIM_TYPE,
PRIM_TYPE_CYLINDER,
PRIM_HOLE_DEFAULT, // hole_shape
< .75, 1, 0.0 >, // cut
0.95, // hollow
< 0.0, 0.0, 0.0 >, // twist
< 1.0, 1.0, 0.0 >, // top_size
< 0.0, 0.0, 0.0 > // top_Shear
}
]);
}
}
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
08-13-2009 06:22
Your brackets do not match!
For a start you have a "[" without a "]" and you have a form:{[}], where curly and square brackets are conflicting.
I don't want to look for more...
Happy scripting:)
_____________________
From Studio Dora
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-13-2009 06:32
From: SirFency Blackheart
Could someone look at this and let me know what I'm doing wrong?

Everything.

Really, your formatting is all screwed up. You did not enclose vector in brackets in the if test, you used just the start bracket for vector in the else if test. That unclosed bracket screws up everything past it.

Your first llSetPrimitiveParams([ never closed at all.

the second llSetPrimitiveParams([ closed outside the else if bracket.

would suggest using LSLEditor as it will help with your formatting and point out the problems:

CODE

default {
state_entry() {
llSay(0, "Hello, Avatar!");
}

touch_start(integer total_number) {
if ((vector) cut == < .75, 1, 0.0 >) {
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_CYLINDER, PRIM_HOLE_DEFAULT, // hole_shape
< 0, 1, 0.0 >, // cut
0.95, // hollow
< 0.0, 0.0, 0.0 >, // twist
< 1.0, 1.0, 0.0 >, // top_size
< 0.0, 0.0, 0.0 >]); // top_Shear
}
else if ((vector) cut == < 0, 1, 0.0 >) {
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_CYLINDER, PRIM_HOLE_DEFAULT, // hole_shape
< .75, 1, 0.0 >, // cut
0.95, // hollow
< 0.0, 0.0, 0.0 >, // twist
< 1.0, 1.0, 0.0 >, // top_size
< 0.0, 0.0, 0.0 >]); // top_Shear
}
}
}



But of course this will still not work because of the lack of logic in the script. How can you test for "cut" when it has not been declared yet? If you do declare it then declare it as a vector and get rid of the two (vector) casts.

And also if I remember correctly; I do not think you can compare vectors.
_____________________
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
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
08-13-2009 06:42
OK well the whole point of me doing this is to have the breadbox open and close using pathcut if I connot compare the two values I dont understand how to make this happen.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
08-13-2009 07:06
Since you're just switching between two values for the vector cut, rather than try to compare vectors and things, why not have a simple binary test and close the thing if it's open and open it if it's closed? Something on the lines of
CODE
vector cut;
integer toggle;

default {

state_entry() {


}

touch_start(integer n) {

toggle =!toggle; // simple binary switch
if(toggle){ // if toggle is true
cut = < 0.75, 1.0, 0.0 >;
}
else{ //it must be false
cut = < 0.0, 1.0, 0.0 > ;
}
llSetPrimitiveParams( [
PRIM_TYPE, PRIM_TYPE_CYLINDER, PRIM_HOLE_DEFAULT,
cut,
0.95, // hollow
< 0.0, 0.0, 0.0 >, // twist
< 1.0, 1.0, 0.0 >, // top_size
< 0.0, 0.0, 0.0 >
]);
}
}

Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-13-2009 07:07
You do not have to compare, just set it one or the other. We use integer switches in a case like this and a user defined function keeps you from having to type out everything twice:

CODE

integer open;

params(vector input) {
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_CYLINDER, PRIM_HOLE_DEFAULT, // hole_shape
input, // cut
0.95, // hollow
< 0.0, 0.0, 0.0 >, // twist
< 1.0, 1.0, 0.0 >, // top_size
< 0.0, 0.0, 0.0 >]); // top_Shear
}

default {
touch_start(integer total_number) {
if (open = !open) {
params(< 0, 1, 0.0 >);
}
else {
params(< .75, 1, 0.0 >);
}
}
}

Do a search in the script library for doors and chests to see other example of the way we code it.
_____________________
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
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-13-2009 07:12
From: Innula Zenovka
CODE

Wonder if you beat me by a full minute or maybe it was right on the edge and it was only a few seconds :D
_____________________
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
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-13-2009 07:22
CODE

integer switch;//not declared so this defaults to TRUE

default {
touch_start(integer n) {
if(switch = !switch){//This is testing if switch == TRUE
//and it also changes it back and
//forth between TRUE & FALSE
//everytime it is tested
llOwnerSay("ON");
}
else{
llOwnerSay("OFF");
}
}
}
_____________________
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
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-13-2009 07:22
i tried to do it in steps, did i get my math wrong somewhere? i don't understand why this isn't working right, and please correct for where i had to to put the stupid space in the vectors

CODE

vector closed = < 0,.25,0>;
vector open = < .23,.25,0>;
vector cut;

integer steps = 8;

docut(vector cutit)
{
llSetPrimitiveParams([
PRIM_TYPE,PRIM_TYPE_CYLINDER,
PRIM_HOLE_DEFAULT,
cutit,
0.95,
< 0.0, 0.0, 0.0>,
< 1.0, 1.0, 0.0>,
< 0.0, 0.0, 0.0>
]);
}
default {
state_entry()
{
docut(closed);
cut = (open-closed)/steps;
llOwnerSay((string)cut);
}

touch(integer num)
{
integer i;
while((++i) < steps)
{
list params = llGetPrimitiveParams([PRIM_TYPE]);
docut(llList2Vector(params,2) + cut);
}
cut = -cut;

}
}


edit: whoops, i realized what i did
but how about this one without steps?

CODE

integer open;
list cuts = [< 0,.25,0>,< .23,.25,0>];

default {
touch_start(integer total_number)
{
llSetPrimitiveParams([
PRIM_TYPE,PRIM_TYPE_CYLINDER,
PRIM_HOLE_DEFAULT,
llList2Vector(cuts,open = !open),
0.95,
< 0.0, 0.0, 0.0>,
< 1.0, 1.0, 0.0>,
< 0.0, 0.0, 0.0>
]);
}
}
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
08-13-2009 07:40
Thanks for all the help guys. I'm obviosly not a scripter but I thought I was on the right track. Its working now.

From: Innula Zenovka
Since you're just switching between two values for the vector cut, rather than try to compare vectors and things, why not have a simple binary test and close the thing if it's open and open it if it's closed? Something on the lines of
CODE
vector cut;
integer toggle;

default {

state_entry() {


}

touch_start(integer n) {

toggle =!toggle; // simple binary switch
if(toggle){ // if toggle is true
cut = < 0.75, 1.0, 0.0 >;
}
else{ //it must be false
cut = < 0.0, 1.0, 0.0 > ;
}
llSetPrimitiveParams( [
PRIM_TYPE, PRIM_TYPE_CYLINDER, PRIM_HOLE_DEFAULT,
cut,
0.95, // hollow
< 0.0, 0.0, 0.0 >, // twist
< 1.0, 1.0, 0.0 >, // top_size
< 0.0, 0.0, 0.0 >
]);
}
}

Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-13-2009 07:49
:p
CODE

vector cut = < 0, 1, 0 >;
float step = .15;

default {
touch_start(integer total_number) {
do {
cut.x += step;
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_CYLINDER, PRIM_HOLE_DEFAULT, // hole_shape
cut, // cut
0.95, // hollow
< 0.0, 0.0, 0.0 >, // twist
< 1.0, 1.0, 0.0 >, // top_size
< 0.0, 0.0, 0.0 >]);
}
while (cut.x > 0 && cut.x < .75);
step *= -1;
}
}

_____________________
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
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-13-2009 07:51
From: SirFency Blackheart
Thanks for all the help guys. I'm obviosly not a scripter but I thought I was on the right track. Its working now.

You took the first steps thou and that is all that matters. It all begins to make sense after a while. Never be bashful about coming here and asking questions.
_____________________
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
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-13-2009 07:52
overkill? i wrote this one up so it would remember what the other params are so it would retain any other stuff you do to it and only mess with the path cut

CODE

integer open;
list cuts = [< 0,.25,0>,< .23,.25,0>];

default {
touch_start(integer total_number)
{
list params = llGetPrimitiveParams([PRIM_TYPE]);
list doparams = [PRIM_TYPE] + llList2List(params,0,1) + [llList2Vector(cuts,open = !open)] +
llList2List(params,3,6);
llSetPrimitiveParams(doparams);
}
}
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369