Hi all,
I am writing a script that will do this:
1. Check if there are lights in the scene.
2. If there are no lights, create 3 point lighting and then link it to a point helper object.
3. But if there are lights in the scene, don't create new lights, select the lights and pass it into an empty array.
The problems I am having are that I can't seem to get the script to check the scene for lights.
Cheers
/Saij
Here is my code:
(
sLights = #()
if sLights.count != 0
then append sLights (for l in lights where ClassOf l != light collect l) else
fn lightCreate = --Ligh Creator
(
local alignObj = Point pos:[0,0,0] size:25 box:true cross:false Name:"AlignObj"
local keyLight = TargetDirectionallight name:(uniqueName"KeyLight") rgb:(color 255 255 255) shadowColor:(color 0 0 0) multiplier:1 pos:[600,-540,540] isSelected:on target:(Targetobject transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]))
local fillLight = targetSpot name:(uniqueName "FillLight_" rgb:(color 255 255 255) multiplier:0.5 pos:[-890,-630,410] isSelected:on target:(Targetobject transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]))
local rimLight = targetSpot name:(uniqueName "RimLight_") rgb:(color 255 255 255) multiplier:0.3 pos:[-100,890,70] isSelected:on target:(Targetobject transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]))
lightArray = (for l in lights where ClassOf l != light collect l)
lightArray.parent = alignObj
)
append sLights (lightCreate())
)
Comments (6)
Comment policy
Thanks guys,
I am save yet again, thanks so much.
Cheers
/saij
Yep, you are right. That is better solution for sure.
I convert lights collection to array because Saij
mentioned in #3 question. But no need to select lights to create array.
no prob ;)
my tips was written to Saij.
Yes, Lights is builtin dynamic collection
You can convert that collection to Array using As operator, but if that's the whole script, I not see a reason to do that. Also I see that you'll link your lights to a Point helper in both cases, so why not to create that Point and then if no lights
create only new lights with your function, and finally link them, i.e. something like this:
one more example
you can also use point helper as target object
if (lightsArr = lights as array).count != 0 then lightsArr else
(
local dm = Point(), lightsArr = #()
for i = 1 to 3 do
(
in dm (lgt = mr_Sky_Portal light_Width:30 light_length:30 pos:[random -100 100,random -100 100,random -100 100])
append lightsArr lgt
)
lightsArr.target = dm ; lightsArr
)
try this one
if (lightsArr = lights as array).count != 0 then lightsArr else
(
local dm = Dummy(), lightsArr = #()
for i = 1 to 3 do
(
in dm (lgt = Omnilight pos:[random -100 100,random -100 100,random -100 100])
append lightsArr lgt
)
lightsArr
)