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 


Having a delay in a debug function.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Flux.
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 88
Location: Another World - N5X2 106311411+2123518

PostPosted: Wed Feb 26, 2020 4:28 pm    Post subject: Having a delay in a debug function. Reply with quote

Hello all, more help needed.

Have being trying to do some stuff with debugging on Breakpoints this evening,
and i wanted to know if there's a way to have a delay in the function,
because the value changes so fast its not recognized.
Code:
function debugger_onBreakpoint()
base = RCX
registerSymbol("base")
  if base == 0x64 then
    writeBytes(base, 0x00)
     --DELAY  (500ms)                 
    writeBytes(base, 0X64)
  end
end

Couldn't find any info on this, any ideas ?
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 62

Joined: 01 Oct 2008
Posts: 958

PostPosted: Wed Feb 26, 2020 10:57 pm    Post subject: This post has 1 review(s) Reply with quote

May create a timer and set the second statement inside OnTimer function.

If using recent ce 7.1 (may need beta 2?), there is a one-time-off version timer can be run like (not tested):
Code:
...
writeBytes(base, 0X00)
createTimer(500, function()writeBytes(base, 0X64) end)
...


However, if you want to 'freeze' the target address to 0x00 before delay end and set back 0x64 after delay, then the onTimer function may set like (and use a smaller interval):

Code:

local delay = 500
...
timer = timer or createTimer()
timer.Interval = 25
local cnt = delay // 25
timer.onTimer = function (tmr)
  cnt = cnt - 1
if cnt>0 then -- freeze
  writeBytes(base, 0X00)
else -- restore and stop timer
  writeBytes(base, 0X64)
  tmr.Enabled = false
end
end


ADDED:
Should base be an address?
It seem the test:if base == 0x64 ... not look right.
May be: if readBytes(base) == 0x64 ?
and
lua registerSymbol need the address parameter too.
Code:

registerSymbol(symbolname, address, OPTIONAL donotsave): Registers a userdefined symbol. If donotsave is true this symbol will not get saved when the table is saved
unregisterSymbol(symbolname)

_________________
- Retarded.
Back to top
View user's profile Send private message
Flux.
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 88
Location: Another World - N5X2 106311411+2123518

PostPosted: Thu Feb 27, 2020 6:05 am    Post subject: Reply with quote

Hello panraven,

Thank you posting some examples, going to see what i can do with them now.

yes i didn't post the full script but there is an address line in there, using debug_setBreakpoint(address,1, bptExecute, bpmDebugRegister).
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