local propsrv = lgs.PropertySrv
local objsrv = lgs.ObjectSrv
local stimsrv = lgs.ActReactSrv
local linksrv = lgs.LinkSrv

local function IDBrowser(ID)
	print("Eteindre!!!!!  ",ID)
	if objsrv.Exists(ID) then
		if objsrv.InheritsFrom(ID,-12) and propsrv.Possessed(ID,"DesignNote") then
			if propsrv.Get(ID,"DesignNote") == "AmTorch" then
				stimsrv.Stimulate(ID,-389,1,ID)
				if propsrv.Possessed(script.objid,"DesignNote") then
					local nouv = objsrv.Create(objsrv.Named(propsrv.Get(script.objid,"DesignNote")))
					local place = objsrv.Position(ID)
					place.z = place.z + (propsrv.Get(ID, "PhysDims", "Size").z )/2
					objsrv.Teleport(nouv,place)
				end
			elseif propsrv.Get(ID,"DesignNote") == "AmLamp" then
				linksrv.Create('ControlDevice',script.objid,ID)
			end
		end
	end
	if ID < script.objid then
		IDBrowser(ID+1)
	end
end

function TurnOn(msg)
	print('>>>Lecture')
	IDBrowser(1)
	linksrv.BroadcastOnAllLinks(script.objid,'TurnOff','ControlDevice')
	print('>>>Fin')
	return true
end