AggrorJorn Posted December 16, 2009 Share Posted December 16, 2009 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 . Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 16, 2009 Share Posted December 16, 2009 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... Quote 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 More sharing options...
AggrorJorn Posted December 16, 2009 Author Share Posted December 16, 2009 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. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 17, 2009 Author Share Posted December 17, 2009 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.