Motion Scripting Question
|
Dag Lavecchia
Registered User
Join date: 6 Dec 2009
Posts: 11
|
01-27-2010 12:26
I think this is the correct place to post this..? Anyway.
I'm looking to make a simple square prim do two things:
1. When the avatar touches the prim, I want it to rotate perpendicularly.
2. More importantly, when the avatar touches the prim, I want it to light up aka turn its 'glow'/brightness to 100 percent. Like turning on a light.
Any recommendations for solving these questions?
|
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
|
01-27-2010 13:08
Rotations make my brain hurt, so I'll leave that to someone else. Glow merely hurts my eyes  default { touch_start (integer count) { llSetPrimitiveParams ([PRIM_GLOW, ALL_SIDES, 1.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE]); } } }
This will do what you ask. You may well find that 100% glow is way over the top, and that a smaller value will look far better: try 0.25 too. You might also want to consider having the object become a light source and perhaps restricting the glow to only some of the prim faces, and you will certainly want to consider turning it all off again too. How to do this is explained here: http://wiki.secondlife.com/wiki/Llsetprimitiveparams, and if that's too daunting feel free to ask more questions in the forum.
|
Dag Lavecchia
Registered User
Join date: 6 Dec 2009
Posts: 11
|
01-27-2010 13:17
I'm actually very new to SL so I honestly can't even follow what your link is trying to explain to me. I input the script and it worked brilliantly, lit the prim up perfectly! I dont know what to do (aka how to script) to make that same prim now turn off...
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
01-27-2010 13:19
Yeah. Glow is nasty and it's unkind to your neighbors too. Glow penetrates any 32-bit texture, so if you have, say, a wall with an alpha texture on it, people on the other side will see your light bulb as if it were radioactive. As a matter of practice, I generally avoid glow altogether. If there's no other alternative, I never use a glow setting greater than 0.05. You ought to be able to make a decent lightbulb with a combination of PRIM_FULLBRIGHT and PRIM_POINT_LIGHT.
_____________________
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 
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
01-27-2010 13:24
From: Dag Lavecchia I'm actually very new to SL so I honestly can't even follow what your link is trying to explain to me. I input the script and it worked brilliantly, lit the prim up perfectly! I dont know what to do (aka how to script) to make that same prim now turn off... Glow, point light, and fullbright are prim properties. You need to turn them on or off manually with Edit tools or by script. To turn them on and off by touch, you need something like this... integer ON; default { touch_start(integer num) { llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,ON= !ON, PRIM_POINT_LIGHT,ON,<1,1,1>,1.0,20.0,0.01]); } }
_____________________
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 
|
Dag Lavecchia
Registered User
Join date: 6 Dec 2009
Posts: 11
|
01-27-2010 13:29
Ok let me see...
|
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
|
01-27-2010 13:33
This is the same script changed to turn things off: default { touch_start (integer count) { llSetPrimitiveParams ([PRIM_GLOW, ALL_SIDES, 0.0, PRIM_FULLBRIGHT, ALL_SIDES, FALSE]); } }
Combining the two to give a touch on, touch off script makes it look like this: integer LIGHT_ON = FALSE;
default { state_entry () { llSetPrimitiveParams ([PRIM_GLOW, ALL_SIDES, 0.0, PRIM_FULLBRIGHT, ALL_SIDES, FALSE]); } touch_start (integer count) { if (LIGHT_ON == FALSE) { llSetPrimitiveParams ([PRIM_GLOW, ALL_SIDES, 1.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE]); LIGHT_ON = TRUE; } else { llSetPrimitiveParams ([PRIM_GLOW, ALL_SIDES, 0.0, PRIM_FULLBRIGHT, ALL_SIDES, FALSE]); LIGHT_ON = FALSE; } } }
This is a long-winded way of writing it but it makes what's happening much clearer than in this: integer LIGHT;
default { state_entry () { llSetPrimitiveParams ([PRIM_GLOW, ALL_SIDES, 0.0, PRIM_FULLBRIGHT, ALL_SIDES, FALSE]); } touch_start (integer count) { if (LIGHT = !LIGHT) llSetPrimitiveParams ([PRIM_GLOW, ALL_SIDES, (float) LIGHT, PRIM_FULLBRIGHT, ALL_SIDES, LIGHT]); } }
|
Dag Lavecchia
Registered User
Join date: 6 Dec 2009
Posts: 11
|
01-27-2010 13:49
Heheh..i cant really wrap my head around this. Do you write all this in one script or multiple scripts? One script to turn on and off?
|
Dag Lavecchia
Registered User
Join date: 6 Dec 2009
Posts: 11
|
01-27-2010 13:52
after the first 'ON' where its ON= it says name not defined within scope
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
01-27-2010 13:52
That's it. The whole script. Right there as I wrote it. Pop it on your light bulb and click it. Unless I made a typo, it should turn the thing on or off with a touch. (Don't include the .. tags, BTW. Those are formatting for the forums)
_____________________
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 
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
01-27-2010 13:56
From: Dag Lavecchia after the first 'ON' where its ON= it says name not defined within scope Be sure that the line that says "integer ON;" before "default" isn't missing. If it is, then you'll get that message. Also, check the way you typed it. "ON = !ON " Spaces don't make a difference, but capitalization does.
_____________________
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 
|
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
|
01-27-2010 14:00
Use just the one script. Rolig's example will toggle the full brightness and the light source properties on and then off. This example is written in a less shorthand way and might be clearer (and it includes both the glow effect - much as that makes me cringe - and the light source effect which lights up the surroundings): integer LIGHT_ON;
default { touch_start (integer count) { if (LIGHT_ON == FALSE) { llSetPrimitiveParams ([PRIM_GLOW, ALL_SIDES, 1.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_POINT_LIGHT, TRUE, <1.0, 1.0, 1.0>, 1.0, 20.0, 0.01]); LIGHT_ON = TRUE; } else { llSetPrimitiveParams ([PRIM_GLOW, ALL_SIDES, 0.0, PRIM_FULLBRIGHT, ALL_SIDES, FALSE, PRIM_POINT_LIGHT, FALSE, <1.0, 1.0, 1.0>, 1.0, 20.0, 0.01]); LIGHT_ON = FALSE; } } }
PS: when you say you want a perpendicular rotation, do you meant you want it to turn 90 degrees in a particular direction, or are you looking for a 180 degree turn?
|
Dag Lavecchia
Registered User
Join date: 6 Dec 2009
Posts: 11
|
01-27-2010 14:03
Okay. I copied it exactly how you typed it.
What it does now is it dims it when i click it once, and then the dimmness goes back to normal again and so on and so forth. Also a little icon that looks like a scripting icon pops up above it...
|
Dag Lavecchia
Registered User
Join date: 6 Dec 2009
Posts: 11
|
01-27-2010 14:07
Wait a minute. This may actually be what you're talking about. It's dim in comparison to glow haha, but i changed its texture to blank and when i turn full bright on, I suppose it kinda lights up. I'd still like it a bit brighter but. There's still this constant scripting symbol above it that's kind of annoying. When i click on it, this comes up :
|
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
|
01-27-2010 14:11
Ah, I think the script error might be that the llSetPrimitiveParams rule list is less forgiving of types, and doesn't like seeing the un-typecast integer ON in the PRIM_GLOW value where it expects a float.
|
Dag Lavecchia
Registered User
Join date: 6 Dec 2009
Posts: 11
|
01-27-2010 14:13
Object: llSetPrimitiveParams error running rule #3 (PRIM_POINT_LIGHT): arg #5 is missing.
Thats the error. But yes its bright now!
|
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
|
01-27-2010 14:15
Oops, we both forgot the intensity value. I've edited my post #11 script to correct that.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
01-27-2010 14:19
Heh, heh.... Pete's right. I told you it should work, barring typos. You're looking at the typo queen of SL. I went back and added intensity to my post too. Sorry about that. 
_____________________
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 
|
Dag Lavecchia
Registered User
Join date: 6 Dec 2009
Posts: 11
|
01-27-2010 14:22
Works like a charm now! Thank you soo much!
Okay, for the motion portion. I'm looking to more or less rotate something 90 degrees around one edge. Imagine the hand of a clock that is pointing at 6. I want to be able to click on that hand and have it rotate (slowly if possible) to point at 9. Then when you click on it, it rotates back down to the 6.
I dont know if that makes sense... like push a panel in a wall and the panel pops out and up, perpendicular to the wall.
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
01-27-2010 14:25
From: Rolig Loon llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,ON= !ON, PRIM_POINT_LIGHT,ON,<1,1,1>,1.0,20.0,0.01]);
I would recommend NOT using ON in two places and modifying it in one. Try: ON=!ON; llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,ON, PRIM_POINT_LIGHT,ON,<1,1,1>,1.0,20.0,0.01]);
|
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
|
01-27-2010 14:27
Yup, that makes sense.
I'm not about to go public with any rotations until I've had a chance to test them in-world (and I should know better than to post llSetPrimitiveParams rule lists without testing them first, either).
Someone will probably show you the full monty before I get a chance to do that.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
01-27-2010 14:34
From: Argent Stonecutter I would recommend NOT using ON in two places and modifying it in one. Try:
ON=!ON; llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,ON, PRIM_POINT_LIGHT,ON,<1,1,1>,1.0,20.0,0.01]); Doing it in one place like this never fails for me, Argent. What's the problem?
_____________________
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 
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
01-27-2010 14:40
From: Rolig Loon Doing it in one place like this never fails for me, Argent. What's the problem? Order of evaluation. Is it going to evaluate the first "ON=!ON" before or after it uses "ON" in the second place in the expression? Will it still do it if you recompile in Mono? Will it still do it if you recompile two years from now? You can't "test this out", because the order is not defined anywhere. Linden Lab is free to optimize it any way they want. Including calculating "temp=!ON" before the whole statement, and "ON=temp" at the end, if that happens to be more efficient. In my career I have seen every possible combination actually used, in other languages. AND, the original Mono implementation evaluated expressions in a different order than LSL. I discovered that and let LL know it would have broken one of Strife's common hacks, and they changed the implementation to avoid that... but if I hadn't discovered that it would have caused a world of pain.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
01-27-2010 14:47
From: Argent Stonecutter Order of evaluation.
Is it going to evaluate the first "ON=!ON" before or after it uses "ON" in the second place in the expression?
Will it still do it if you recompile in Mono?
Will it still do it if you recompile two years from now?
Actually, in practice, it does evaluate the first instance before the second one in both LSO and Mono. I've tested that and have been doing simple switches like this successfully for quite a while. But your point about long-term stability is well taken. We can't count on LL doing anything the same from one year to the next. Thanks.
_____________________
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
|
01-27-2010 15:55
values in a list (or a function) are evaluated left to right from the commas, but right to left between them...
but I'd agree with argent that it's safer to only use in place assignment where that value isn't being reused in the list/function call.
you can do it, and it's valid and will work, but I wouldn't count on it long term...
same goes for any assignment inside a statement where the variable is used more than once... = += -= *= /= %= ++ and --, I'd recommend avoiding using any of those on a variable when there's multiple reads of that variable in the statement... it's a huge target for getting broken
_____________________
| | . "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... | - 
|