Message passing to render script (SOLVED)

I would like to change a color of an ambient light dynamically, so I thought adding this to the render script’s on_message function:

	elseif message_id == "change_ambient_light" then
    		print("Render","changing ambient light to", message.light)
    		self.ambient_light = message.light or vmath.vector4(0.05, 0.05, 0.1, 0.1)
    		update_window(self)
        end

and sending a trigger message (in main script’s init after 10 seconds):

	timer.delay(10, false, function() 
		msg.post("@render:", "change_ambient_light", { light = vmath.vector4(0.8, 0.1, 0.05, 0.2) } )
		print("sent")
	end)

would do, but it’s not working - even "Render",... message isn’t printed, so I’m quessing the message is sent to the void ("sent" is printed) :confused: Would you please tell me, what am I doing wrong? Is it even possible or should I do something else?

Message IDs are hashed. Try:

elseif message_id == hash("change_ambient_light") then
4 Likes

Hah :smiley: how could I miss it? sometimes it’s good to show a code to someone :stuck_out_tongue: thank you!

2 Likes