er2.setTimeOfDay 89

Sets the current time of day of the mission. NOTE: This function is CPU heavy


Return value

Return TypeDescription
voidThis function doesn't return anything

Parameters

ParameterTypeDescription
1integerThe hour of the day. Must stay between 0 and 23, otherwise will be set to 0
2integerThe minute of the day. Must stay between 0 and 59, otherwise will be set to 0

Examples

Example 33

-- set 4:20 PM
local currentHour = 16;
local currentMinute = 20;
er2.setTimeOfDay(currentHour, currentMinute)

-- or simply
er2.setTimeOfDay(16, 20)

Example 34

--starts at 8 AM
local currentHour = 8;
local currentMinute = 0;
er2.setTimeOfDay(currentHour,currentMinute)

--increase daytime each 0.1 seconds
while true do
	sleep(.1)

	--increase by 1 minute
	currentMinute = currentMinute+1
        
        --every 60 minutes reset minute counter and increase hours
	if currentMinute >=60 then
		currentMinute = 0
		currentHour = currentHour+1

                -- every 24 hours reset hours counter
		if currentHour>=24 then
			currentHour = 0
		end
	end

	-- set new daytime value
	er2.setTimeOfDay(currentHour,currentMinute)
end

Back to Scripting API