melt / time delay shrink
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-20-2008 18:59
i'm trying to write a script that will make a candle appear to scale down over time. i could easily just change the scale, but i want it to move as well (the bottom should be fixed on the base) i would just use a tortured prim (bottom dimpled cylinder) but this is a sculpted candle i'm working with here's the script. i'm getting a syntax error in between the parenthesis in the else statement of the timer, not sure why From: someone integer on; vector startscale; vector startpos; float melt = 0.01; vector move = <0.0,0.0,melt>; float delay = 60.0;
startover() { llSetScale(startscale); llSetPos(llGetRootPosition() + startpos); } default { state_entry() { startscale = llGetScale(); startpos = llGetLocalPos(); }
touch_start(integer total_number) { if (on) { llSetTimerEvent(delay); } else { llSetTimerEvent(0.0); startover(); } } timer() { vector scale = llGetScale(); float endzscale = startscale.z * melt; if (scale.z == endzscale) { startover(); } else () { llSetScale(llGetScale() - move); llSetPos(llGetPos() - move * llGetRot()); } }
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-20-2008 19:20
Only if or else if test and need parenthesis. In other words: else {
_____________________
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
|
10-20-2008 19:36
/me smacks himself in the head...DUH!! lol
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-20-2008 19:39
Corrected a couple more problems: integer on = 1;//*********** vector startscale; vector startpos; float melt = 0.01; vector move = <0.0, 0.0, melt>; float delay = 1.0;
startover(){ llSetScale(startscale); llSetPos(startpos);//works like this for single prim, not sure on linked child? }
default { state_entry() { startscale = llGetScale(); startpos = llGetLocalPos(); } touch_start(integer total_number) { if (on) { llSetTimerEvent(delay); } else { llSetTimerEvent(0.0); startover(); } on = !on;//********** } timer() { vector scale = llGetScale(); float endzscale = startscale.z * melt; if (scale.z == endzscale) { startover(); } else { llSetScale(llGetScale() - move); llSetPos(llGetPos() - (move/2) * llGetRot());//********** } } }
_____________________
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
|
10-20-2008 19:57
thanks  and actually i found i had to leave (vector move) blank and then define it in the state entry, otherwise it just returns a zero vector, and it seems it's not moving the prim when it scales it, i'll have to convert it to llSetPrimitiveParams i guess. i wish there was a llSetLocalPos. i work on it some more and probably post it for the library also, why are you dividing the movement by 2?
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-20-2008 20:12
From: Ruthven Willenov thanks  and actually i found i had to leave (vector move) blank and then define it in the state entry, otherwise it just returns a zero vector, and it seems it's not moving the prim when it scales it, i'll have to convert it to llSetPrimitiveParams i guess. i wish there was a llSetLocalPos. i work on it some more and probably post it for the library also, why are you dividing the movement by 2? Try it in a prim by itself. Should give you a better idea of what to change for a child prim. movement/2 because it was both scaling it and moving it down. Also startscale.z * melt was too small and stub would start to move down, changed to startscale.z * melt * 5 and it works nice. vector move worked fine where you had it in Aditi using MONO. Fun script and great idea btw! Debugging is the easy part. integer on = 1; vector startscale; vector startpos; float melt = 0.01; float endzscale; vector move = <0.0, 0.0, melt >; float delay = 0.5;
startover(){ llSetScale(startscale); llSetPos(startpos); }
default { state_entry() { startscale = llGetScale(); endzscale = startscale.z * melt * 5;//*************** startpos = llGetLocalPos(); } touch_start(integer total_number) { if (on) { llSetTimerEvent(delay); } else { llSetTimerEvent(0.0); startover(); } on = !on; } timer() { vector scale = llGetScale(); if (scale.z <= endzscale) { llSetTimerEvent(0.0);//*********************** startover(); } else { llSetScale(llGetScale() - move); llSetPos(llGetPos() - (move / 2) * llGetRot()); } } }
_____________________
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
|
10-20-2008 20:13
ok here's this with llSetPrimitiveParams, but it's not doing anything From: someone integer on; vector startscale; vector startpos; float meltpercent = 0.05; float melt; vector move; float delay = 5.0;
startover() { llSetPrimitiveParams([PRIM_SIZE, startscale, PRIM_POSITION, llGetRootPosition() + startpos]); } default { state_entry() { startscale = llGetScale(); startpos = llGetLocalPos(); melt = startscale.z * meltpercent; move = <0.0,0.0,melt>; }
touch_start(integer total_number) { if (on) { llSetTimerEvent(delay); } else { llSetTimerEvent(0.0); startover(); } on = !on; } timer() { vector scale = llGetScale(); float endzscale = startscale.z * melt; if (scale.z == endzscale) { startover(); } else { llSetPrimitiveParams([PRIM_SIZE, llGetScale() - move, PRIM_POSITION, llGetPos() - (move/2) * llGetRot()]); } } }
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-20-2008 20:23
ah, you posted while i was making a new post lol, yeah it works for a single prim, but it's gonna be a child prim. i'll later incorporate it into an object that has other functions. i'm just using this with the switch for testing. and i notice the melt process isn't starting over when it gets to the end, it just goes back to the original size and scale. there's nothing there to turn the timer off except in the touch event
edit: nevermind, i just noticed you were turning it off in the timer event when it got to the end, i only needed it to turn off if it was touched to turn it off
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-20-2008 20:29
Finally. This works perfectly in a candle that is a child prim (candle in a holder?) integer on = 1; vector startscale; vector startpos; float melt = 0.01; float endzscale; vector move = <0.0, 0.0, melt>; float delay = 0.5;
startover(){ llSetScale(startscale); llSetPos(startpos); }
default { state_entry() { startscale = llGetScale(); endzscale = startscale.z * melt * 5; startpos = llGetLocalPos(); } touch_start(integer total_number) { if (on) { llSetTimerEvent(delay); } else { llSetTimerEvent(0.0); startover(); } on = !on; } timer() { vector scale = llGetScale(); if (scale.z <= endzscale) { llSetTimerEvent(0.0); startover(); } else { llSetScale(llGetScale() - move); llSetPos((llGetLocalPos() - move / 2) * llGetRot());//************** } } }
Now the fun part is going to be getting a flame to move down as the candle burns  I'll leave that for you while I go get my beauty sleep! EDIT: BTW I turned off the timer inside if (scale.z <= endzscale) { in my previous post. Have a good night Ruthven!
_____________________
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
|
10-20-2008 20:34
haha, yeah, that I THINK, i can manage with a link message so that each time the candle "melts" it'll send a link message to the wick to move similarly to how the candle is but without the scale change
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-20-2008 21:09
well it seems to be working mostly, except it moves along the x axis while it's melting, not sure why. once i get that debugged i'll work on moving the wick with it edit: aha, it's because the base isn't a zero rotation, so i needed to use llGetLocalRot, instead of llGetRot From: someone integer on = 1; vector startscale; vector startpos; float meltpercent = 0.1; float melt; vector move; float delay = 0.5; startover(){ llSetScale(startscale); llSetPos(startpos); } default { state_entry() { startscale = llGetScale(); startpos = llGetLocalPos(); melt = startscale.z * meltpercent; move = <0.0,0.0,melt>; } touch_start(integer total_number) { if (on) { llSetTimerEvent(delay); } else { llSetTimerEvent(0.0); startover(); } on = !on; } timer() { vector scale = llGetScale(); if (scale.z <= melt) { startover(); } else { llSetScale(llGetScale() - move); llSetPos(llGetLocalPos() - (<0.0,0.0,melt/2>  * llGetLocalRot());//************** } } }
|