Jump to content

light script on/off by chat


MIVIMEX
 Share

You are about to reply to a thread that has been inactive for 2112 days.

Please take a moment to consider if this thread is worth bumping.

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!

Link to comment
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.

Link to comment
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
Link to comment
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
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2112 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...