Well I tried your way, and the the script in the switch was no correct. I think it would have worked, but I had the problem that light that was created inside the lamp, could shine through walls. If I would drag a regular lamp in screen, this didn't happen. Also I would like to leave the script for the light alone.
I tried this and it worked! Instead of sending messages, I just used the show() and hide() commando's. This is script for the switch:
require("scripts/class")
local class=CreateClass(...)
class.sound_switch=LoadSound("abstract::switch.wav")
function class:CreateObject(model)
local object=self.super:CreateObject(model)
local lightOn=1
function object:ReceiveMessage(message,extra)
local n
local target
local args
local delay
if message=="use" then
if class.sound_switch~=nil then
PlaySound(class.sound_switch)
end
local n,target,targetmessage,args,delay
for n=0,7 do
target=self.model:GetTarget(n)
if target~=nil then
if lightOn==1 then
target:Hide()
lightOn=0
else
target:Show()
lightOn=1
end
end
end
end
end
end