Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

On and Off - script for light?

PetGirl Bergman
Fellow Creature:-)
Join date: 16 Feb 2005
Posts: 2,414
09-11-2005 00:50
On and Off - script for light?

Light on / light of - by ”touch” -??? or any better suggestion(s)

Any that know where I can find that or how to make one..

Then pls remember I cant a thing about scripts.-)))

Make my Sunday or Monday a great day pls:-))))) *smiles*

/PetGirl (Tina) Made in Sweden:-)))
a lost user
Join date: ?
Posts: ?
09-11-2005 01:55
I am assuming you just mean to make a prim change from Light material to another material and back again with on a touch, like a light switch? The other method would be to use particles or even textures.. heck even color change from grey to white for example but I'll just assume you mean changing the material.

CODE
default
{
state_entry()
{
// llSetLinkColor(LINK_THIS,<0.5,0.5,0.5>,ALL_SIDES);
// llSetTexture("light off picture",ALL_SIDES);
llSetPrimitiveParams([PRIM_MATERIAL, PRIM_MATERIAL_WOOD]);
}

touch_start(integer num)
{
state on;
}
}

state on
{
state_entry()
{
// llSetLinkColor(LINK_THIS,<1.0,1.0,1.0>,ALL_SIDES);
// llSetTexture("light on picture",ALL_SIDES);
llSetPrimitiveParams([PRIM_MATERIAL, PRIM_MATERIAL_LIGHT]);
}

touch_start(integer num)
{
state default;
}
}


The particle system is the same, I just don't have one handy to use as an example. Basically you have llParticleSystem([]) for the off (default state), and the llParticleSystem([list of particle settings]) for the on (on state).

If you want to have a separate light switch, just send llSay() or llShout() messages to the light script, so here's a simple script for the light switch:
CODE
integer output = 333; // channel that lights will listen to
default
{
state_entry()
{
llShout(output,"off");
}

touch_start(integer num)
{
state on;
}
}

state on
{
state_entry()
{
llShout(output,"on");
}

touch_start(integer num)
{
state default;
}
}


And this is the script that would go in the lights:
CODE
integer input = 333; // channel that switch is sending on
default
{
state_entry
{
llListen(input,"","","");
}

listen(integer channel, string name, key id, string message)
{
if(message == "on")
{
// llSetLinkColor(LINK_THIS,<1.0,1.0,1.0>,ALL_SIDES);
// llSetTexture("light on picture",ALL_SIDES);
llSetPrimitiveParams([PRIM_MATERIAL, PRIM_MATERIAL_LIGHT]);
}

if(message == "off")
{
// llSetLinkColor(LINK_THIS,<0.5,0.5,0.5>,ALL_SIDES);
// llSetTexture("light off picture",ALL_SIDES);
llSetPrimitiveParams([PRIM_MATERIAL, PRIM_MATERIAL_WOOD]);
}
}
}
PetGirl Bergman
Fellow Creature:-)
Join date: 16 Feb 2005
Posts: 2,414
09-11-2005 03:18
OH MY!! Tks I do a try.. nice.. very nice!! Tackar!