|
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
|
08-30-2007 09:36
hope someone can help me , i think the term is "flow control" being very new to scripting , i made a script based on a post i read by Vares Solvang here /54/c7/137951/1.html using llSetPrimitiveParams to open up "hollow" a door , i would like to tidy up the script to make it neater and possibly smoother by using steps instead of using the llSetPrimitiveParams several times over but after a week of reading the wiki and forum posts all i manage to do is alter the time the door "says" open or closed using "integer steps = 5, and for (i = 0; i < steps; i++)" .Any help would be greatly appreciated ,code is as follows
integer on = TRUE;
default { state_entry() { }
touch_start(integer total_number) { if (on == TRUE) { llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, // hole_shape <0.0, 1.0, 0.0>, // cut 0.0, // hollow <0.0, 0.0, 0.0>, // twist <1.0, 1.0, 0.0>, // taper <0.0, 0.0, 0.0> // top_Shear ]);
llSay(0, "Door Closed"); on = FALSE; } else if (on == FALSE) { llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, // hole_shape <0.0, 1.0, 0.0>, // cut .15, // hollow <0.0, 0.0, 0.0>, // twist <1.0,1.0, 0.0>, // taper <0.0, 0.0, 0.0> // top_Shear ]); llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, // hole_shape <0.0, 1.0, 0.0>, // cut .30, // hollow <0.0, 0.0, 0.0>, // twist <1.0,1.0, 0.0>, // taper <0.0, 0.0, 0.0> // top_Shear ]); llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, // hole_shape <0.0, 1.0, 0.0>, // cut .45, // hollow <0.0, 0.0, 0.0>, // twist <1.0,1.0, 0.0>, // taper <0.0, 0.0, 0.0> // top_Shear ]); llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, // hole_shape <0.0, 1.0, 0.0>, // cut .60, // hollow <0.0, 0.0, 0.0>, // twist <1.0,1.0, 0.0>, // taper <0.0, 0.0, 0.0> // top_Shear ]); llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, // hole_shape <0.0, 1.0, 0.0>, // cut .75, // hollow <0.0, 0.0, 0.0>, // twist <1.0,1.0, 0.0>, // taper <0.0, 0.0, 0.0> // top_Shear ]); llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, // hole_shape <0.0, 1.0, 0.0>, // cut .85, // hollow <0.0, 0.0, 0.0>, // twist <1.0,1.0, 0.0>, // taper <0.0, 0.0, 0.0> // top_Shear ]); llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, // hole_shape <0.0, 1.0, 0.0>, // cut .95, // hollow <0.0, 0.0, 0.0>, // twist <1.0,1.0, 0.0>, // taper <0.0, 0.0, 0.0> // top_Shear ]); llSay(0, "Door Open"); on = TRUE; } } }
|
|
Mortus Allen
Registered User
Join date: 28 Apr 2007
Posts: 528
|
08-30-2007 10:15
it does look like you are looking to use a "for" loop, which you say you have tried. Perhaps if you can post your code with the "for" loop, we can take a look and see where you may have gone wrong.
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
08-30-2007 17:03
Try something more like this
integer open = TRUE; integer steps = 50; float delayBetweenSteps = 0.02; default { state_entry() { }
touch_start(integer total_number) { if (open == TRUE) { llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, // hole_shape <0.0, 1.0, 0.0>, // cut 0.0, // hollow <0.0, 0.0, 0.0>, // twist <1.0, 1.0, 0.0>, // taper <0.0, 0.0, 0.0> // top_Shear ]);
llSay(0, "Door Closed"); open = FALSE; } else if (open == FALSE) { integer i; for(i=0;i<steps;i++) { llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, // hole_shape <0.0, 1.0, 0.0>, // cut (float)(i)/(float)steps, // hollow <0.0, 0.0, 0.0>, // twist <1.0,1.0, 0.0>, // taper <0.0, 0.0, 0.0> // top_Shear ]); llSleep(delayBetweenSteps); }
llSay(0, "Door Open"); on = TRUE; } } }
|
|
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
|
08-31-2007 02:28
thanks for your help ppl , Mortus i tried the "for" loop virtually everywhere i could get it to syntax lol , and Shadow , i tried your code , got it to compile but no luck , it did,nt do anything to the prim , i thought that was what was needed some code inside the parameters part of the llSetPrimitiveParams function but did,nt know how to syntax it, unfortunately it seems to need something else to make it work. Many thanks again for your help.
|
|
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
|
08-31-2007 04:17
Ok finally got it at last , it needed a float for the holesize , works a treat thankyou for pointing me in the right direction shadow , new code is as follows integer open = TRUE; integer steps = 50; float delayBetweenSteps = 0.02; float holesize = 0.95; default { state_entry() {
}
touch_start(integer total_number) { if (open == TRUE)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, // hole_shape <0.0, 1.0, 0.0>, // cut 0.0, // hollow <0.0, 0.0, 0.0>, // twist <1.0, 1.0, 0.0>, // taper <0.0, 0.0, 0.0> // top_Shear ]);
llSay(0, "Door Closed"); open = FALSE; } else if (open == FALSE) { integer i; for(i=0;i<steps;i++) {
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, // hole_shape <0.0, 1.0, 0.0>, // cut (float)(i)/(float)steps*holesize, // hollow <0.0, 0.0, 0.0>, // twist <1.0,1.0, 0.0>, // taper <0.0, 0.0, 0.0> // top_Shear ]); llSleep(delayBetweenSteps); }
llSay(0, "Door Open"); open = TRUE; } }
}
EDIT. Most sincere apologies Shadow , your code worked as was , i copied badly so holesize was,nt required.once again many thanks.
|