Code archives/Miscellaneous/b+ CreateDelayTimer(length)

This code has been declared by its author to be Public Domain code.

Download source code

b+ CreateDelayTimer(length) by skn32004
Blitz timers are designed to trigger at a constant rate, rather than wait a speciffic time amount.

The function CreateDelayTimer, will create and return a timer, who's first "tick" occurs, at your specified length.

The timer will continue to tick, so it is upto you to deal with it after the initial event.

Note: b3d uses a different timer system, so this will not work correctly! It will however work perfectly in b+
Function CreateDelayTimer(length)
	Local timerlength#
	If length > 1000
		timerlength# = 1.0 / (length / 1000.0)
		Return CreateTimer(timerlength#)
	Else
		timerlength# = 1000.0 / length
		Return CreateTimer(timerlength#)
	End If
End Function

Comments

Perturbatio2004
Typo:

tiemrlength# = 1000.0 / length



skn32004
haha well spotted, thanks


Code Archives Forum