The example doesn't work from the example provided. Well, i can't really see how i can sepparate in multiple levels since the user is creating a level by constantly placing the elements in the scene, i can't put any restriction

.
Here is my code for the lights, its a bit long so i trully apologise:
//ADD LIGHTS
//POINT LIGHT
//READ LIGHT PROPERTIES
if file exist("point") = 1
//CLEAR OLD LIGHTMAPS
lm clear collision objects
lm clear light map objects
lm clear lights
//ADD SHADOW COLLISION TO OBJECTS
for objaddcollisionobject = 1 to 100000
if object exist(objaddcollisionobject) = 1
LM Add Collision Object objaddcollisionobject
ENDIF
NEXT objaddcollisionobject
LM Build collision Data
//ADD OBJECTS TO LIGHT MAPPING PROCESS
for objaddtolightmap = 1 to 100000
if object exist(objaddtolightmap) = 1
LM Add Light Map Object objaddtolightmap
ENDIF
NEXT objaddtolightmap
//CONFIGURE LIGHT MAPPING PROCESS
lm set ambient light 0.4, 0.4, 0.4
lm set ambient occlusion on 15, 5, 1
//CREATE LIGHT REPRESENTATION
inc lit
make object sphere lit, 25
position object lit, camera position x(0),camera position y(0),camera position z(0)
if file exist("currentmap") = 1
open to read 2, "currentmap"
if file open(2) = 1
read string 2, tempcurentmap$
endif
close file 2
endif
if file exist("Media Packs\Scripts\Lights\" + tempcurentmap$ + "\" + str$(lit)) = 1
open to read 3, "Media Packs\Scripts\Lights\" + tempcurentmap$ + "\" + str$(lit)
if file open(3) = 1
read string 3, reprange$
read string 3, repcolorr$
read string 3, repcolorg$
read string 3, repcolorb$
endif
close file 3
ENDIF
color object lit, rgb(val(repcolorr$), val(repcolorg$), val(repcolorb$))
//DELETE LIGHT ADDING DETECTION
delete file "point"
ENDIF
//SPOT LIGHTS
if file exist("spot") = 1
//CLEAR OLD LIGHTMAPS
lm clear collision objects
lm clear light map objects
lm clear lights
//ADD SHADOW COLLISION TO OBJECTS
for objaddcollisionobject = 1 to 100000
if object exist(objaddcollisionobject) = 1
LM Add Collision Object objaddcollisionobject
ENDIF
NEXT objaddcollisionobject
LM Build collision Data
//ADD OBJECTS TO LIGHT MAPPING PROCESS
for objaddtolightmap = 1 to 100000
if object exist(objaddtolightmap) = 1
LM Add Light Map Object objaddtolightmap
ENDIF
NEXT objaddtolightmap
//CONFIGURE LIGHT MAPPING PROCESS
lm set ambient light 0.4, 0.4, 0.4
lm set ambient occlusion on 15, 5, 1
//CREATE LIGHT REPRESENTATION
inc spot
make object cone spot, 85
position object spot, camera position x(0), camera position y(0), camera position z(0)
set object wireframe spot, 0
if file exist("currentmap") = 1
open to read 5, "currentmap"
if file open(5) = 1
read string 5, tempcurentmap$
endif
close file 5
endif
if file exist("Media Packs\Scripts\Lights\" + tempcurentmap$ + "\" + str$(spot)) = 1
open to read 6, "Media Packs\Scripts\Lights\" + tempcurentmap$ + "\" + str$(spot)
if file open(6) = 1
read string 6, repspotrange$
read string 6, repspotcolorr$
read string 6, repspotcolorg$
read string 6, repspotcolorb$
endif
close file 6
ENDIF
color object spot, rgb(val(repspotcolorr$), val(repspotcolorg$), val(repspotcolorb$))
//DELETE LIGHT ADDING DETECTION
delete file "spot"
endif
//START SCENE RENDERING
if file exist("renderscene") = 1
if file exist("currentmap") = 1
open to read 5, "currentmap"
if file open(5) = 1
read string 5, currentmap$
endif
close file 5
endif
//ADD SHADOW COLLISION TO OBJECTS
for objaddcollisionobject = 1 to 100000
if object exist(objaddcollisionobject) = 1
LM Add Collision Object objaddcollisionobject
ENDIF
NEXT objaddcollisionobject
LM Build collision Data
//ADD OBJECTS TO LIGHT MAPPING PROCESS
for objaddtolightmap = 1 to 100000
if object exist(objaddtolightmap) = 1
LM Add Light Map Object objaddtolightmap
ENDIF
NEXT objaddtolightmap
//CONFIGURE LIGHT MAPPING PROCESS
lm set ambient light 0.4, 0.4, 0.4
lm set ambient occlusion on 15, 5, 1
//ADD POINT LIGHTS - RENDER
for lightfiles = 200001 to lit
if file exist("Media Packs\Scripts\Lights\" + currentmap$ + "\" + str$(lightfiles)) = 1
open to read 3, "Media Packs\Scripts\Lights\" + currentmap$ + "\" + str$(lightfiles)
if file open(3) = 1
read string 3, range$
read string 3, pointcolorr$
read string 3, pointcolorg$
read string 3, pointcolorb$
endif
close file 3
if object exist(lightfiles) = 1
LM Add Point Light object position x(lightfiles),object position y(lightfiles),object position z(lightfiles),val(range$),val(pointcolorr$), val(pointcolorg$), val(pointcolorb$)
color object lightfiles, rgb(val(pointcolorr$), val(pointcolorg$), val(pointcolorb$))
endif
ENDIF
NEXT lightfiles
//ADD SPOT LIGHTS - RENDER
for spotlightfiles = 300001 to spot
if file exist("Media Packs\Scripts\Lights\" + currentmap$ + "\" + str$(spotlightfiles)) = 1
open to read 4, "Media Packs\Scripts\Lights\" + currentmap$ + "\" + str$(spotlightfiles)
if file open(4) = 1
read string 4, spotrange$
read string 4, spotpointcolorr$
read string 4, spotpointcolorg$
read string 4, spotpointcolorb$
endif
close file 4
if object exist(spotlightfiles) = 1
LM Add Spot Light object position x(spotlightfiles),object position y(spotlightfiles),object position z(spotlightfiles), 25, 25, 25, 45, 45, val(spotrange$),val(spotpointcolorr$), val(spotpointcolorg$), val(spotpointcolorb$)
color object spotlightfiles, rgb(val(spotpointcolorr$), val(spotpointcolorg$), val(spotpointcolorb$))
endif
ENDIF
NEXT spotlightfiles
//SET LIGHT MAPPER SETTINGS - QUALITY AND BUILD THE LIGHTS
LM Build Light Maps Thread 2024,4024,1024
//LOAD DLL TO HALT APPLICATION FOR RENDERING
load dll "Kernel32.dll",1
//TURN GPU SYNCRONIZATION
sync off
//LIGHT MAPPER LOOP
while LM Get Complete()=0
//HALT APPLICATION FOR RENDERING
call dll 1,"Sleep",100
//CLEAR SCREEN
cls
//DISPLAY RENDERING STATUS ON INTERFACE
if file exist("renderstatus") = 1
delete file "renderstatus"
endif
open to write 1, "renderstatus"
if file open(1) = 1
write string 1, str$(LM Get Percent())
endif
close file 1
endwhile
//TURN ON GPU SYNCRONIZATION
sync on
//TERMINATE LIGHT MAPPING PROCESS
lm terminate thread
//RESET LIGHT MAPPER
LM Reset
//DELETE HALT APPLICATION DLL FOR RENDERING PROCESS
delete dll 1
//DELETE SCENE RENDERING DETECTION FILE
delete file "renderscene"
endif
Alex Matei CEO
www.alexmatei.com