sleep 7

Pause the execution of the LUA script for some time. Notice: this is very helpful to give some pause to the CPU, expecially during 'while' and 'for' loops


Return value

Return TypeDescription
voidThis function doesn't return anything

Parameters

ParameterTypeDescription
1floatAmount of seconds to pause the script for

Examples

sleep(3)
sleep (0.01)
float randomTime = math.random(2.0, 3.0) --random time between 2 and 3 seconds

sleep(randomTime)
--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