createTimer

From Cheat Engine
Revision as of 05:18, 11 March 2017 by TheyCallMeTim13 (talk | contribs)
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

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

Examples

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

Related Classes