How do I swap worlds?

So I can create a world with python with New()
and I can get a list of worlds linked to a scene with Get()


1/ How do I find out which world is used when I render the scene?

2/ How do I change/swap the world used?

That’s exactly what I’ve been trying to find out for my G Buffer script:

No one has offered an answer either here or at .org and I can’t find anything in the API docs. It would be very irriating if this was not possible…

I want a world with a black sky to use in a
specular render pass. I make the world but
I can’t get it into the scene or the rendercontext
or whatever.

I screwed around for an hour this morning
with print dir(*) on everything in sight
but I can’t see anything that might work.

I suppose I could workaround using the
render context
or the backbuffer
or deleting/unlinking all the worlds.
But it’s annoying having a hole in the API like that.

:stuck_out_tongue: Say why don’t you add that into your script –
Production/Specular/Reflexion passes.

I was going to set the specular values to 0 on the materials
and set the NoSpecular flag on all the lamps to do the
production pass.

---------------------------here’s the code for the specular pass----------------------

import Blender

#lamps = [obj for obj in  Blender.Object.Get() if obj.getType() == "Lamp"]
meshes = [obj for obj in  Blender.Object.Get() if obj.getType() == "Mesh"]

allMats ={}
for mesh in meshes:
	for mat in
			allMats[] = mat
#save color settings
colors = {}
for n,mat in allMats.items():
	colors[mat] = (mat.R,mat.G, mat.B) 

#paint it black
for n,mat in allMats.items():
	mat.R= mat.B =mat.G = 0
myScene =Blender.Scene.GetCurrent()
mySettings = myScene.getRenderingContext()
myDir = mySettings.getRenderPath()

#restore colors
for mat,col in colors.items():
	mat.R, mat.G, mat.B = col