Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


using CE to output a variable continuously

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
dantirya
How do I cheat?
Reputation: 0

Joined: 17 May 2019
Posts: 4

PostPosted: Fri May 17, 2019 11:02 am    Post subject: using CE to output a variable continuously Reply with quote

Hello!

I'm wondering if its possible to use CE to read an internal variable on another process and output its value to a text file every few seconds?

Seems to me like this is something CE can do but I'm rather at a loss as to where to start trying to make this happen.

Thanks for your time!
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri May 17, 2019 12:07 pm    Post subject: Re: using CE to output a variable continuously Reply with quote

dantirya wrote:
... use CE to read an internal variable on another process


Maybe, you meant 'on a process'.

This is a sample to print out the score changed on The Windows game, Solitaire.
Said, I already have an address for score value and I want to know score change every 5 seconds.

Code:
local al = AddressList or getAddressList()
local mr1 = al.getMemoryRecordByDescription("No Description")
if not mr1 then error("Memrecs do not exist!!!") end

function hack1()
 val = mr1.Value
 val = tonumber(val)
 if val <= 0 then
  t.enabled = false
  print('Value = '..val)
 else
  print(os.date()..'  | value = '..val)  -- show changed value each 5 seconds and his changed time
 end
end

t = createTimer()
t.interval = 5000
t.onTimer = hack1
t.enabled = true

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
dantirya
How do I cheat?
Reputation: 0

Joined: 17 May 2019
Posts: 4

PostPosted: Fri May 17, 2019 8:22 pm    Post subject: Reply with quote

If I'm following the code correctly that will output the value to.... the console?
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri May 17, 2019 9:11 pm    Post subject: Reply with quote

Yes. I just give you sample and thought made improvisation. Next code, to save the result to a text file.

Code:
local al = AddressList or getAddressList()
local mr1 = al.getMemoryRecordByDescription("No Description")
if not mr1 then error("Memrecs do not exist!!!") end

local stringlist = createStringlist()
local path = TrainerOrigin or getMainForm()
local myfile = path .. "\\myresult.txt"

function hack1()
 val = mr1.Value
 val = tonumber(val)
 if val <= 0 then
  t.enabled = false
  stringlist.saveToFile(myfile)
 else
 stringlist.add(os.date()..'  | value = '..val)
 print(os.date()..'  | value = '..val)
 end
end

t = createTimer()
t.interval = 5000
t.onTimer = hack1
t.enabled = true


It will give results as text file contains:

Code:
05/18/19 10:02:58  | value = 38
05/18/19 10:03:03  | value = 36
05/18/19 10:03:08  | value = 36
05/18/19 10:03:13  | value = 34
05/18/19 10:03:18  | value = 34
05/18/19 10:03:23  | value = 32
05/18/19 10:03:28  | value = 32
05/18/19 10:03:33  | value = 30
05/18/19 10:03:38  | value = 30
05/18/19 10:03:43  | value = 28
05/18/19 10:03:48  | value = 28
05/18/19 10:03:53  | value = 26
05/18/19 10:03:58  | value = 26
05/18/19 10:04:03  | value = 24
05/18/19 10:04:08  | value = 24
05/18/19 10:04:13  | value = 22
.. and so on till 0

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
dantirya
How do I cheat?
Reputation: 0

Joined: 17 May 2019
Posts: 4

PostPosted: Tue May 21, 2019 1:21 am    Post subject: Reply with quote

thank you for the examples!
Back to top
View user's profile Send private message
dantirya
How do I cheat?
Reputation: 0

Joined: 17 May 2019
Posts: 4

PostPosted: Tue May 21, 2019 9:26 pm    Post subject: Reply with quote

I don't fully understand the stringlist.add method and the stringlist class isn't well documented on the cheatengine wiki

is it possible to destructively overwrite the output instead of appending to the end of the file?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites