How to create a timer ?

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
User avatar
Blayde
Expert Cheater
Expert Cheater
Posts: 186
Joined: Fri Aug 25, 2017 2:37 pm
Reputation: 34
Contact:

How to create a timer ?

Post by Blayde » Sun Jan 07, 2018 2:30 am

Help. I feel stuck and stupid. :lol:

I need a timer to read value (constantly).

al = getAddressList()
mr = al.getMemoryRecordByDescription("Description here")
CEEditBox.Text = mr.Value

User avatar
TheyCallMeTim13
Expert Cheater
Expert Cheater
Posts: 64
Joined: Fri Mar 03, 2017 12:31 am
Reputation: 5

Re: How to create a timer ?

Post by TheyCallMeTim13 » Sun Jan 07, 2018 4:08 am

Code: Select all

--------
-------- Timer
--------
local aTimer = nil
local aTimerInterval = 10
local aTimerTicks = 0
local aTimerTickMax = 0
local function aTimer_tick(timer)
	if aTimerTickMax > 0 and aTimerTicks >= aTimerTickMax then
		timer.destroy()
	end
	aTimerTicks = aTimerTicks + 1
	-- body
end
aTimer = createTimer(getMainForm(), false)
aTimer.Interval = aTimerInterval
aTimer.OnTimer = aTimer_tick
aTimer.Enabled = true
Generated with: I2 CE Lua Script Template Generator

User avatar
FreeER
Expert Cheater
Expert Cheater
Posts: 59
Joined: Fri Mar 10, 2017 7:11 pm
Reputation: 6
Contact:

Re: How to create a timer ?

Post by FreeER » Sun Jan 07, 2018 3:20 pm

A simpler option might be to let CE handle it whenever it updates the memory record using OnGetDisplayValue

Code: Select all

al = getAddressList()
mr = al.getMemoryRecordByDescription("Description here")

mr.OnGetDisplayValue = function(mr,valuestring)
  --CETrainer.CEEdit1.Text = valuestring -- testing
  CEEditBox.Text = valuestring
end

User avatar
Blayde
Expert Cheater
Expert Cheater
Posts: 186
Joined: Fri Aug 25, 2017 2:37 pm
Reputation: 34
Contact:

Re: How to create a timer ?

Post by Blayde » Sun Jan 07, 2018 4:16 pm

FreeER wrote:
Sun Jan 07, 2018 3:20 pm
A simpler option might be to let CE handle it whenever it updates the memory record using OnGetDisplayValue

Code: Select all

al = getAddressList()
mr = al.getMemoryRecordByDescription("Description here")

mr.OnGetDisplayValue = function(mr,valuestring)
  --CETrainer.CEEdit1.Text = valuestring -- testing
  CEEditBox.Text = valuestring
end
Thanks.
I'll do some tests and report.


Edit:
Error

Code: Select all

al = getAddressList()
mr = al.getMemoryRecordByDescription("Description here")
mr.OnGetDisplayValue = function(mr,valuestring)
  --CETrainer.CEEdit1.Text = valuestring -- testing
  CEEditBox.Text = valuestring
end
Working

Code: Select all

al = getAddressList()
mr = al.getMemoryRecordByDescription("Description here")
mr.OnGetDisplayValue = function(mr,valuestring)
  CETrainer.CEEdit1.Text = valuestring -- testing
  --CEEditBox.Text = valuestring
end
Thank you

Post Reply

Who is online

Users browsing this forum: No registered users