Jump to content
MIVIMEX

light script on/off by chat

Recommended Posts

Hello! tell me please how should the script of the lighting device look like, which is switched on/off by command in the chat, and illuminates the ambience, but with only one surface glowing?

Danke, Muchos gracias, Thanks!

Share this post


Link to post
Share on other sites

The script should look like well-formatted LSL, following the best practices and examples as shown in the Wiki. I hope that helps!

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
On 29.06.2018 at 10:48 PM, Fionalein said:

see old forum posts...

like this one:

 

Hello! Thank you very much for the answer! Works great!! But what if I need the light to turn on and off on the same command, for example "light".  Hello! thank you very much for the answer! works great!! but what if I need the light to turn on and off on the same command, for example light. You say "light" for the first time and the light turns on. The second time and it turns off.

Share this post


Link to post
Share on other sites

just change a few things in the script...

// define a global

integer toggle;

// change your listen event a bit

listen(integer channel, string name, key id, string message)
{
  if ( message == "light")
   {  

      toggle = !toggle
      // change this part ......if (message == "ON") { ..... to ...
      if ( toggle )
      { // llParticleSystem stuff for ON
      }
      // change this part ......if (message == "OFF") { ..... to ...
      else
      { // llParticleSystem stuff for OFF
      }
  }
}

 

 

 

Edited by Xiija
  • Thanks 1

Share this post


Link to post
Share on other sites

A global variable like

integer gLit;

then, in your default section, state_entry,

gLit = TRUE; (or FALSE, if it is set to "off" to start with), and then in your listen event

if (message == "light" && gLit) {

(function you wrote to light it);

} else

if (message == "light" && !gLit) {

(function you wrote to turn it off);

will determine if it's lit or not lit, and the same command will trigger two different things, such as turning the light on or off.

Same as Xijia's, just different way to go about it. Not as elegant, but I always know what it is and what it does when I see it in a script later (like mental script commenting xD ).

Edited by PheebyKatz

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...