|
Gareth Qunhua
Registered User
Join date: 11 Apr 2007
Posts: 25
|
07-19-2007 12:12
hi there i would like to know how do i scrip a simple lighting scrip, where when i touch the prim with the script only that prim not the whole link prim will turn the light feature on or off. thanks in advance  and is there a way to input a voice command so that i can change the intensity, radius, fall off or colour for it?
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
07-19-2007 12:44
Not sure if the "switch" prim is also the light-emitting prim. If so, you'll want to use llSetPrimitiveParams. If not, llSetLinkPrimitiveParams, called with the link number of the light-emitting prim. In either case, it's PRIM_POINT_LIGHT settings you'll adjust. Oh, and to prevent the whole contraption from acting like the switch, be sure the switch-scripted prim is *not* the root prim.
As for chat (I assume not "voice" qua *voice*), sure, you just need to llListen() and do settings from the listen() event handler, according to whatever "light command language" you devise. If you can use a channel other than standard chat (0), that would be best; if it has to be channel 0, then at least use something like a "light_on" state so it's only listening when there's light to adjust. (Personally, instead of chat, I'd use one or more touch-activated dialogs for these settings--one selection from which would be "turn off"--given that the user is already touching the prim anyway.)
|
|
Gareth Qunhua
Registered User
Join date: 11 Apr 2007
Posts: 25
|
07-19-2007 23:49
thanks a lot thats what i was looking for  and umm sorry to bother again but how do you script it so that when you touch the prim it will change PRIM_POINT_LIGHT to true when touch and false when touch again? and how do you make it so that when you rez it the PRIM_POINT_LIGHT would be set to false by default?
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
Sample script
07-20-2007 08:18
Ok, well, sorry for this: Qie totally sucks at pedagogy.  Here's some kinda start. // Qie Niangao released for any use 2007-07-20. // // If placed in non-root prim, only that prim will switch on/off the lighting prim.
integer LIGHT_LINK_NUM = 1; //the linked prim whence the light emanates. (1 is root) integer LIGHT_CHANNEL = 1; //chat channel. "/1bright" makes the light bright, for example. float DIM = 0.3; float BRIGHT = 0.9; float NARROW = 5.0; //narrow radius float BROAD = 15.0; //wide radius float RAMP = 0.75; //gradual falloff float STEP = 0.0; //abrupt falloff list colorList = [ "yellow", <1,1,0> , "white", <1,1,1> , "blue", <0,0,1> , "red", <1,0,0> , "green", <0,1,0> , "magenta", <1,0,1> , "cyan", <0,1,1> ]; float intensity = BRIGHT; float radius = BROAD; float falloff = RAMP; integer colorNameIndex = 0; integer listenHandle;
setLight(integer on) { llSetLinkPrimitiveParams(LIGHT_LINK_NUM, [PRIM_POINT_LIGHT, on, llList2Vector(colorList, colorNameIndex + 1), intensity, radius, falloff]); }
default { state_entry() { state light_off; } }
state light_off { state_entry() { setLight(FALSE); } touch_start(integer num_detected) { state light_on; } }
state light_on { state_entry() { setLight(TRUE); listenHandle = llListen(LIGHT_CHANNEL, "", NULL_KEY, ""); } on_rez(integer start_param) { llResetScript(); } touch_start(integer num_detected) { state light_off; } listen(integer channel, string name, key id, string message) { string msg = llToLower(message); integer tempColorNameIndex; if("bright"==msg) intensity = BRIGHT; else if("dim"==msg) intensity = DIM; else if("narrow"==msg) radius = NARROW; else if("broad"==msg) radius = BROAD; else if("ramp"==msg) falloff = RAMP; else if("step"==msg) falloff = STEP; else if(-1 != (tempColorNameIndex = llListFindList(colorList, [msg]))) colorNameIndex = tempColorNameIndex; else return; setLight(TRUE); } state_exit() { llListenRemove(listenHandle); } }
|
|
Gareth Qunhua
Registered User
Join date: 11 Apr 2007
Posts: 25
|
07-22-2007 00:51
thanks a lot the script is what i wanted, though still it is a little bug where the prim with the script is set to be the switch but the root prim will glow, i have tried converting it to llSetPrimitiveParams from llSetLinkPrimitiveParams but an error message would show up. is there a way to set it so that only the prim with the script will glow instead of the root prim glowing?
|
|
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
|
07-22-2007 03:39
llSetPrimitiveParams doesn't take a link number, so just remove "LIGHT_LINK_NUM," when you change it to use llSetPrimitiveParams:
llSetPrimitiveParams([PRIM_POINT_LIGHT, on, llList2Vector(colorList, colorNameIndex + 1), intensity, radius, falloff]);
|
|
Gareth Qunhua
Registered User
Join date: 11 Apr 2007
Posts: 25
|
07-22-2007 06:23
thanks alot it works fine now 
|
|
Leyah Renegade
Live Musician
Join date: 2 Nov 2006
Posts: 125
|
07-27-2007 11:17
Great script!
Is there a way to change the "full bright" property of a prim to on or off?
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
07-27-2007 12:04
From: Leyah Renegade Is there a way to change the "full bright" property of a prim to on or off? Yep, per side or all at once, with a rule like PRIM_FULLBRIGHT, ALL_SIDES, TRUE added to the llSetPrimitiveParams call.
|