Saxum/data/levels/scripts/sunUpdate.lua
2015-03-06 16:19:57 +01:00

22 lines
601 B
Lua

local global = require( "global" )
function trigger(objectToChange)
if(global.triggeredSunStart) then
if(not level) then
print("No level found in Lua!")
return
end
local maxTimeDiff = 20
local timeDiff = os.clock()- global.sunStartTime
if(timeDiff > maxTimeDiff)then
timeDiff = maxTimeDiff
end
timeDiff = timeDiff/maxTimeDiff
local x = 1 - 0.3 * timeDiff
local y = math.sqrt(timeDiff) * 1.0 - 0.1
local z = 0.7 * timeDiff
level:setSunDirection(x,y,z)
end
end