Jump to content

light and switch messages


AggrorJorn
 Share

Recommended Posts

I'm trying to make a switch work for turning on and of lights. First problem is, is that I can turn the light of (hide message), but then I can't get it back on (show message.) I use these messages in the switch.lua:

 if entity.hidden==1 then
                                       target:SendMessage("show",nil,delay)
                               else
                                       target:SendMessage("hide",nil,delay)
                               end

.

Link to comment
Share on other sites

I'm trying to make a switch work for turning on and of lights. First problem is, is that I can turn the light of (hide message), but then I can't get it back on (show message.) I use these messages in the switch.lua:

 if entity.hidden==1 then
                                       target:SendMessage("show",nil,delay)
                               else
                                       target:SendMessage("hide",nil,delay)
                               end

.

 

need more code than that to troubleshoot... where are you setting entity.hidden to a 1 after you turn off the light? that if-statement is looking for entity.hidden==1 to turn on the light...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

The script I'm using is an entire copy of the original switch. It is exactly the same now, appart from the messages "activate" and " deactivate", which I replaced with Hide and Show. The base.lua message function looks like this.

if message=="hide" then
	entity.model:Hide()
	entity.hidden=1
elseif message=="show" then
	entity.model:Show()
	entity.hidden=0

 

I have added the entity.hidden=1 and entity.hidden=0 here.

Link to comment
Share on other sites

I also tried to make my own messages: "LightOn" and "lightOf". This way I can call the entity.light instead of hiding the the lamp. It's the same as show and hide, but the difference is is that I can call light entities that are in a fixed position like the cagelight. But also here: I can only turn it off and not back on.

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...