createTimer

From Cheat Engine
Jump to navigation Jump to search

function createTimer(Owner OPTIONAL, Enabled OPTIONAL) : Timer

Returns a newly created timer object.

If enabled is not given it will be enabled by default (will start as soon as an onTimer event has been assigned)

Owner may be nil, but you will be responsible for destroying it instead of being the responsibility of the owner object)


Tip: use getMainForm for the owner of any timer so that it is destroyed when the main form is destroyed (closed).

createTimer(getMainForm())

Function Parameters[edit]

Parameter Type Description
Owner Control or Component based object The owner of the timer (used for resource clean up)
Enabled boolean The timer's enable state, set to false to disable timer on creation.

Examples[edit]

local timer = createTimer(getMainForm())
timer.Interval = 100
timer.OnTimer = function(timer)
  -- code setting done state.
  if DoneState == true then
    timer.destroy()
  end
end
local mainForm = getMainForm()
local function timer_tick(timer)
  -- code setting done state.
  if DoneState == true then
    timer.destroy()
  end
end
local someTimer = createTimer(mainForm, false)
someTimer.Interval = 100
someTimer.OnTimer = timer_tick
someTimer.Enabled = true


See also[edit]

Related Classes[edit]