Difference between revisions of "createTimer"

From Cheat Engine
Jump to navigation Jump to search
(Created page with ''''function''' createTimer(''Owner'' OPTIONAL, ''Enabled'' OPTIONAL) ''':''' Timer Returns a newly created timer object. If enabled is not given it will be enabled by defau…')
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
[[Category:Lua]]
 
'''function''' createTimer(''Owner'' OPTIONAL, ''Enabled'' OPTIONAL) ''':''' [[Timer]]
 
'''function''' createTimer(''Owner'' OPTIONAL, ''Enabled'' OPTIONAL) ''':''' [[Timer]]
  
Line 9: Line 10:
  
 
Tip: use [[getMainForm]] for the owner of any timer so that it is destroyed when the main form is destroyed (closed).
 
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===
 
===Function Parameters===
Line 23: Line 24:
 
|Enabled
 
|Enabled
 
|boolean
 
|boolean
|The [[Timer]]s enable state, set to false to disable [[Timer]] on creation.
+
|The timer's enable state, set to false to disable timer on creation.
 
|}
 
|}
  

Latest revision as of 13:12, 19 March 2017

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]