Why i can't edit any type of light properties?

ERROR:SCRIPT: main/game/skybox_controller.script:101: ‘/sun1#ambient_light’ does not have any property called ‘color’
stack traceback:
[C]:-1: in function set
main/game/skybox_controller.script:101: in function <main/game/skybox_controller.script:9>

go.property("time_speed", 0.11) 
go.property("clock_time", 12.0) 

function init(self)
	self.shader_time = 0
end

function update(self, dt)
	self.clock_time = self.clock_time + (self.time_speed * dt)
	if self.clock_time >= 24.0 then
		self.clock_time = self.clock_time - 24.0
	end

	self.shader_time = self.shader_time + dt

	local angle = ((self.clock_time - 6.0) / 24.0) * (math.pi * 2.0)
	local sun_x = math.cos(angle)
	local sun_y = math.sin(angle)
	local sun_z = 0.3 
	local sun_dir = vmath.normalize(vmath.vector3(sun_x, sun_y, sun_z))

	local night   = vmath.vector4(0.02, 0.02, 0.08, 1.0) 
	local sunrise = vmath.vector4(0.9,  0.4,  0.2,  1.0)  
	local day     = vmath.vector4(1.0,  1.0,  1.0,  1.0)      
	local sunset  = vmath.vector4(0.95, 0.5,  0.25, 1.0)

	local current_tint = day

	local night_amb_col   = vmath.vector3(0.05, 0.05, 0.15)
	local night_amb_int   = 0.1
	local night_dir_col   = vmath.vector3(0.2,  0.3,  0.5)
	local night_dir_int   = 0.05

	local sunrise_amb_col = vmath.vector3(0.4,  0.2,  0.15)
	local sunrise_amb_int = 0.4
	local sunrise_dir_col = vmath.vector3(1.0,  0.5,  0.2)
	local sunrise_dir_int = 0.8

	local day_amb_col     = vmath.vector3(0.8,  0.85, 1.0)
	local day_amb_int     = 0.7
	local day_dir_col     = vmath.vector3(1.0,  0.98, 0.9)
	local day_dir_int     = 1.2

	local sunset_amb_col  = vmath.vector3(0.4,  0.2,  0.15)
	local sunset_amb_int  = 0.4
	local sunset_dir_col  = vmath.vector3(1.0,  0.6,  0.3)
	local sunset_dir_int  = 0.8

	local amb_col, amb_int, dir_col, dir_int

	if self.clock_time >= 0 and self.clock_time < 4 then
		current_tint = night
		amb_col, amb_int, dir_col, dir_int = night_amb_col, night_amb_int, night_dir_col, night_dir_int
	elseif self.clock_time >= 4 and self.clock_time < 6.5 then
		local t = (self.clock_time - 4) / 2.5
		current_tint = vmath.lerp(t, night, sunrise)
		amb_col = vmath.lerp(t, night_amb_col, sunrise_amb_col)
		amb_int = vmath.lerp(t, night_amb_int, sunrise_amb_int)
		dir_col = vmath.lerp(t, night_dir_col, sunrise_dir_col)
		dir_int = vmath.lerp(t, night_dir_int, sunrise_dir_int)
	elseif self.clock_time >= 6.5 and self.clock_time < 9 then
		local t = (self.clock_time - 6.5) / 2.5
		current_tint = vmath.lerp(t, sunrise, day)
		amb_col = vmath.lerp(t, sunrise_amb_col, day_amb_col)
		amb_int = vmath.lerp(t, sunrise_amb_int, day_amb_int)
		dir_col = vmath.lerp(t, sunrise_dir_col, day_dir_col)
		dir_int = vmath.lerp(t, sunrise_dir_int, day_dir_int)
	elseif self.clock_time >= 9 and self.clock_time < 16.5 then
		current_tint = day
		amb_col, amb_int, dir_col, dir_int = day_amb_col, day_amb_int, day_dir_col, day_dir_int
	elseif self.clock_time >= 16.5 and self.clock_time < 19 then
		local t = (self.clock_time - 16.5) / 2.5
		current_tint = vmath.lerp(t, day, sunset)
		amb_col = vmath.lerp(t, day_amb_col, sunset_amb_col)
		amb_int = vmath.lerp(t, day_amb_int, sunset_amb_int)
		dir_col = vmath.lerp(t, day_dir_col, sunset_dir_col)
		dir_int = vmath.lerp(t, day_dir_int, sunset_dir_int)
	elseif self.clock_time >= 19 and self.clock_time < 21.5 then
		local t = (self.clock_time - 19) / 2.5
		current_tint = vmath.lerp(t, sunset, night)
		amb_col = vmath.lerp(t, sunset_amb_col, night_amb_col)
		amb_int = vmath.lerp(t, sunset_amb_int, night_amb_int)
		dir_col = vmath.lerp(t, sunset_dir_col, night_dir_col)
		dir_int = vmath.lerp(t, sunset_dir_int, night_dir_int)
	else
		current_tint = night
		amb_col, amb_int, dir_col, dir_int = night_amb_col, night_amb_int, night_dir_col, night_dir_int
	end

	go.set("#model", "tint", current_tint)
	go.set("#model", "time", vmath.vector4(self.shader_time, 0, 0, 0))
	go.set("#model", "sun_dir", vmath.vector4(sun_dir.x, sun_dir.y, sun_dir.z, 0))

	
	go.set("/sun1#ambient_light", "color", amb_col)
	go.set("/sun1#ambient_light", "intensity", amb_int)
	go.set("/sun1#directional_light", "color", dir_col)
	go.set("/sun1#directional_light", "intensity", dir_int)
end

It might be that these aren’t exposed to scripts yet. @jhonny.goransson ?

1 Like

Yes there are no exposed properties yet because of technical reasons. People are on vacation right now and we need to discuss this before committing anything. Unfortunately it’s a bit more complicated than to “just expose properties” I’m afraid :slight_smile: but we’ll look at it once everyone is working again.

2 Likes