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 


Is there a way to constantly re-write a value?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
iosufdhgd
Newbie cheater
Reputation: 0

Joined: 04 Jun 2022
Posts: 17

PostPosted: Sat Jun 04, 2022 3:10 pm    Post subject: Is there a way to constantly re-write a value? Reply with quote

My intention is to change a certain value every second or so, to a new value in a list format. There a way to do that without indulging into the scripting aspect of CE?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 155

Joined: 06 Jul 2014
Posts: 4773

PostPosted: Sat Jun 04, 2022 3:28 pm    Post subject: Reply with quote

I'm not sure what exactly you mean by "in a list format," but no, you'll probably have to use Lua to do that. Good news is that it's not difficult.
Code:
local values = { 2, 3, 5, 7, 11 }
local i = 1

if mytimer then mytimer.destroy(); mytimer = nil end
mytimer = createTimer()

mytimer.Interval = 1000
mytimer.OnTimer = function(t)
  writeInteger('foo', values[i])
  i = (i % #values) + 1
end
Learn the Lua language first (plenty of tutorials to cover the basics), then learn the stuff CE adds to Lua (search the forums, look at the CE wiki, read celua.txt).
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
iosufdhgd
Newbie cheater
Reputation: 0

Joined: 04 Jun 2022
Posts: 17

PostPosted: Sat Jun 04, 2022 3:42 pm    Post subject: Reply with quote

ParkourPenguin wrote:
I'm not sure what exactly you mean by "in a list format," but no, you'll probably have to use Lua to do that. Good news is that it's not difficult.
Code:
local values = { 2, 3, 5, 7, 11 }
local i = 1

if mytimer then mytimer.destroy(); mytimer = nil end
mytimer = createTimer()

mytimer.Interval = 1000
mytimer.OnTimer = function(t)
  writeInteger('foo', values[i])
  i = (i % #values) + 1
end
Learn the Lua language first (plenty of tutorials to cover the basics), then learn the stuff CE adds to Lua (search the forums, look at the CE wiki, read celua.txt).


Thanks man Smile

Also, when I say in a list format, I mean I want to change this value to a character in this list.

For example, say the list was:

Code:
a
b
c
d
e
f
g


I would want each character to replace the current value, so that every second the original value would change to a, then b, then c and so on. Only with, many more characters in this list
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 155

Joined: 06 Jul 2014
Posts: 4773

PostPosted: Sat Jun 04, 2022 4:28 pm    Post subject: Reply with quote

Another example using the address list and memory records:
Code:
local chars = {
  'a', 'b', 'c', 'd',
  'e', 'f', 'g', 'h',
-- etc...
}
local i = 1
local mymemrec = AddressList.getMemoryRecordByDescription'foo'

if mytimer then mytimer.destroy(); mytimer = nil end
mytimer = createTimer()

mytimer.Interval = 1000
mytimer.OnTimer = function(t)
  mymemrec.Value = chars[i]
  i = (i % #chars) + 1
end

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
iosufdhgd
Newbie cheater
Reputation: 0

Joined: 04 Jun 2022
Posts: 17

PostPosted: Sat Jun 04, 2022 5:01 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Another example using the address list and memory records:
Code:
local chars = {
  'a', 'b', 'c', 'd',
  'e', 'f', 'g', 'h',
-- etc...
}
local i = 1
local mymemrec = AddressList.getMemoryRecordByDescription'foo'

if mytimer then mytimer.destroy(); mytimer = nil end
mytimer = createTimer()

mytimer.Interval = 1000
mytimer.OnTimer = function(t)
  mymemrec.Value = chars[i]
  i = (i % #chars) + 1
end


Cheers!

Another thing, is it possible to read an offset, then output a string at that offset, to a text file automatically?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 155

Joined: 06 Jul 2014
Posts: 4773

PostPosted: Sat Jun 04, 2022 5:55 pm    Post subject: Reply with quote

If by "offset" you mean "address," sure:
Code:
local f = assert(io.open('file.txt', 'w'))
f:write(readString('[game.exe+1234]+1C', 99))
f:close()

If you want to write to a certain offset in a file, use file:seek(...)

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
iosufdhgd
Newbie cheater
Reputation: 0

Joined: 04 Jun 2022
Posts: 17

PostPosted: Sat Jun 04, 2022 6:40 pm    Post subject: Reply with quote

ParkourPenguin wrote:
If by "offset" you mean "address," sure:
Code:
local f = assert(io.open('file.txt', 'w'))
f:write(readString('[game.exe+1234]+1C', 99))
f:close()

If you want to write to a certain offset in a file, use file:seek(...)


yep, that's all i needed to know
thanks alot for all your help!

EDIT: Also, how do I make this automatic for everytime the string at the address changes?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 155

Joined: 06 Jul 2014
Posts: 4773

PostPosted: Sat Jun 04, 2022 8:35 pm    Post subject: Reply with quote

You could use a timer and check if it has changed.
Code:
local oldvalue

if t then t.destroy(); t = nil end
t = createTimer()
t.Interval = 500
t.OnTimer = function(t)
  local s = readString(address, 99)
  if s and s ~= oldvalue then
    -- it changed: do stuff
    -- ...
    oldvalue = s
  end
end

Timers work up to an interval of about 16-17ms and could miss some changes if they're made faster than this. Use breakpoints or code injection if you can't miss anything.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
iosufdhgd
Newbie cheater
Reputation: 0

Joined: 04 Jun 2022
Posts: 17

PostPosted: Sat Jun 04, 2022 9:02 pm    Post subject: Reply with quote

ParkourPenguin wrote:
You could use a timer and check if it has changed.
Code:
local oldvalue

if t then t.destroy(); t = nil end
t = createTimer()
t.Interval = 500
t.OnTimer = function(t)
  local s = readString(address, 99)
  if s and s ~= oldvalue then
    -- it changed: do stuff
    -- ...
    oldvalue = s
  end
end

Timers work up to an interval of about 16-17ms and could miss some changes if they're made faster than this. Use breakpoints or code injection if you can't miss anything.


Okay, I've implemented that and it seems to do its job. Thanks alot man!

Time to rest lol

Also, in regards to
Code:
local chars = {
  'a', 'b', 'c', 'd',
  'e', 'f', 'g', 'h',
-- etc...
}
local i = 1
local mymemrec = AddressList.getMemoryRecordByDescription'foo'

if mytimer then mytimer.destroy(); mytimer = nil end
mytimer = createTimer()

mytimer.Interval = 1000
mytimer.OnTimer = function(t)
  mymemrec.Value = chars[i]
  i = (i % #chars) + 1
end


My "Chars" are about 30 characters long, so I don't think this would be feasible. Are there any other routes?
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 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