Scripts for my garden furniture
|
|
Sarah Glenelg
Registered User
Join date: 9 Feb 2007
Posts: 8
|
02-10-2007 00:03
Hello, this is my first post so I hope i am posting in the right place. I have just started to build my first objects which are some basic garden furniture. I have been looking for 2 scripts.
The first is for my garden umbrella - I have made an open and closed version - is there a script that would allow my objects to 'morph' from one to the other, giving the impression of opening and closing when touched?
The second is for a garden swing I am making. I would like to put some sit pose balls on the seat and have the sitter experience swinging back and forth.
Any advice or pointing in the right direction gratefully received. Thank you.
|
|
Tyann Toll
It went... where?!
Join date: 17 Dec 2006
Posts: 37
|
02-10-2007 00:28
Immediate thoughts...
The umbrella could be done with llSetPrimitiveParameters() - changing from one shape to another when clicked on, and swopping textures as it does so.
The garden swing might wait for an avatar to sit on it, and then swing using rotation.
|
|
Sarah Glenelg
Registered User
Join date: 9 Feb 2007
Posts: 8
|
02-10-2007 01:44
Thank you, I now have my swing script and it works a treat. Just looking for an open and close one for my umbrella. Thank you
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
02-10-2007 02:47
The easiest way is to have teh open and closed versions in one object and then just turn off the visibility of the one you dont want to see at this time. Use llSetAlpha and llSetLinkAlpha The other way, 'morphing' the shape is to make the umbrella canopy change from its furled form to the open form using llSetPrimitiveParams. Simple Umbrella script // Simple Unbrella //------------------ // Code is verbosely commented to help anyone new to LSL understand its operation. // vector min = < 0.5,0.5,2.5 >; vector max = < 3.0,3.0,0.5 >; float stepsOn = 5.0; // Number of Steps to Take between off and on float stepsOff = 5.0; // Number of Steps to Take between on and off vector step; // will be set to max/steps (for convenience only) vector current; // Current value float timesec = 0.5;
SetSize() { llSetPrimitiveParams([PRIM_SIZE, current]); } //-------------------------------------------------------------------------------------------------- default { on_rez(integer number) { llResetScript();} // If we rez in this state reset the script.
state_entry() { current = min; // Set Start Value SetSize(); } // Touch activation touch_start(integer total_number) // touch activation { state state_on; // change to on state } } //-------------------------------------------------------------------------------------------------- state state_on { on_rez(integer number) { llResetScript();} // If we rez in this state reset the script. state_entry() { current = min; // Current intensity = minimum intensity step = (max-min) / stepsOn; // set up step value SetSize(); llSetTimerEvent(timesec); // Set the timer going } timer() // Timer event { current += step; // Increment the intensity SetSize(); if(current.x >= max.x) // If we have reached the target value { llSetTimerEvent(0); // Cancel the timer } } touch_start(integer total_number) // Touch Control { llSetTimerEvent(0); // Clear the Timer Event for this state state Rundown; // turn it off } } //-------------------------------------------------------------------------------------------------- state Rundown { on_rez(integer number) { llResetScript();} // If we rez in this state reset the script. state_entry() { llSetTimerEvent(timesec); // Set the Timer Event for this state step = (max - min) / stepsOff; // set up step value } timer() { current -= step; // Decrement the intensity SetSize(); if(current.x <= min.x) // If we have reached the target value { llSetTimerEvent(0); // Cancel the timer state default; // back to the default state } } }
|
|
Sarah Glenelg
Registered User
Join date: 9 Feb 2007
Posts: 8
|
02-10-2007 06:20
Thank you Newgate for this script which I have been playing with. I put it into my furled umbrella and it certainly opened up to state very similar to my opened one. Only thing is that it changes the vertical location of the top of the umbrella so that when it is opened it comes too far down my pole or if I adjust the vertical position of the open position, then it goes too high when closed. I changed the 3rd parameter in 'vector min' to be the same as 'vector max' which made the height ok but the rest of the object becomes much too small when closed. Is it possible in this script to change the size and position of the furled umbrella but achieve the same end result of the open one? Thank you for your help.
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
02-10-2007 08:35
Clever, Newgate. Sarah, you can try a couple of things. In the timer, where it says timer() // Timer event { current += step; // Increment the intensity SetSize(); if(current.x >= max.x) // If we have reached the target value { llSetTimerEvent(0); // Cancel the timer } } You need to add a line like llSetPos(<something here>  that moves the umbrella up the pole. You could put it in SetSize() too. The center of the umbrella doesn't move like it needs to.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
02-10-2007 09:24
When I made my umbrella I made the min and max such that it looked 'ok' in both positions rather than add complexity to the script. I ended up shortening the pole a bit since you cant see muh of it in the furled position anyway. Modify the llSetPrimitiveParameters to move the position in the z axis. Not tried this but I think this will work.
SetSize() { vector newpos = llGetPos(); newpos.z -= ((current.z - min.z)/2.0); llSetPrimitiveParams([PRIM_SIZE, current, PRIM_POSITION, newpos]); }
|
|
Marty Starbrook
NOW MADE WITH COCO
Join date: 10 Dec 2006
Posts: 523
|
Swing
02-25-2007 13:30
Ive been looking for a swing myself .....
Theres seems loads and loads of rotate EVERYTHING at various speeds ... but not a lot to swing something.
Martin :L
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
02-26-2007 00:19
From: Marty Starbrook Ive been looking for a swing myself .....
Theres seems loads and loads of rotate EVERYTHING at various speeds ... but not a lot to swing something.
Martin :L oh yes there is! try looking here
|
|
Markus Brendel
Registered User
Join date: 16 Oct 2006
Posts: 13
|
03-08-2007 06:59
Sarah, Would you be willing to share this swing script with me and others? I am in need of the same thing.
|
|
chr0nic MacKay
Registered User
Join date: 12 Jul 2006
Posts: 26
|
04-19-2007 18:54
hey there sarah i would lvoe to get a copy of the swing script from u how much would it cost me ??
thx for yur time reading this rico
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
04-20-2007 00:10
From: chr0nic MacKay hey there sarah i would lvoe to get a copy of the swing script from u how much would it cost me ??
thx for yur time reading this rico Refer to my reply to Marty's post.
|
|
Gene Jacobs
Who? Me?
Join date: 30 Jul 2004
Posts: 127
|
Newgate Ludd's Rocker Script
06-25-2007 20:36
From: Newgate Ludd oh yes there is! try looking hereI like that swing / rocker script... is there a way to make it center back up when it is stopped?
_____________________
SL Defined = The reason that we are all here, is because we are not all there... 
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
06-26-2007 12:06
From: Gene Jacobs I like that swing / rocker script... is there a way to make it center back up when it is stopped? hmmm, easiest way would be to capture the 'start' position in default state entry and then simply restore the values.
_____________________
I'm back......
|