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 


What am I doing wrong? This even possible?

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

Joined: 26 Jan 2018
Posts: 90

PostPosted: Fri Mar 08, 2024 10:11 pm    Post subject: What am I doing wrong? This even possible? Reply with quote

Code:

[ENABLE]
alloc(newmem,2048)
label(code)
label(return)

newmem:
code:
  cmp [8003B9E0],1 // Compare the value at address 8003B9E0 with 1
  jne short return // If not equal, jump to return
  mov [8003B9E0],2 // If equal, move 2 into the address
return:
  jmp newmem // Jump back to newmem to loop the check

// Register the thread that will run our code
CreateThread(newmem)

[DISABLE]
dealloc(newmem)
// If you had registered any symbols, unregister them here
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 147

Joined: 06 Jul 2014
Posts: 4518

PostPosted: Fri Mar 08, 2024 10:44 pm    Post subject: Reply with quote

What are you even trying to do...?

If you're concerned about the crash that happens when the script is disabled, well, that's what happens when you deallocate memory a thread is using.
See this for more information:
https://forum.cheatengine.org/viewtopic.php?t=619046

You're probably better off using a timer anyway. I highly doubt you need to dedicate an entire hardware thread to this single task in a busy loop.
Code:
{$lua}
if syntaxcheck then return end

if myTimer then myTimer.destroy(); myTimer = nil end

[ENABLE]

myTimer = createTimer()

myTimer.Interval = 100
myTimer.OnTimer = function(t)
  if readInteger(0x8003B9E0) == 1 then
    writeInteger(0x8003B9E0, 2)
  end
end

[DISABLE]

If a timer isn't fast enough, try using code injection to modify what writes to the address.

_________________
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
theboy181
Advanced Cheater
Reputation: 0

Joined: 26 Jan 2018
Posts: 90

PostPosted: Fri Mar 08, 2024 11:47 pm    Post subject: Reply with quote

Thanks this was helpful.

This is to make RR64 for the N64 60fps.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 465

Joined: 09 May 2003
Posts: 25509
Location: The netherlands

PostPosted: Sat Mar 09, 2024 2:17 am    Post subject: Reply with quote

You can also freeze the value and set the value to:
Code:

value==1 and 2 or value


you can also put this in a hotkey. 1 hotkey that freezes, and then another hotkey with the same key to set the value

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
theboy181
Advanced Cheater
Reputation: 0

Joined: 26 Jan 2018
Posts: 90

PostPosted: Sat Mar 09, 2024 12:14 pm    Post subject: Reply with quote

Dark Byte wrote:
You can also freeze the value and set the value to:
Code:

value==1 and 2 or value


you can also put this in a hotkey. 1 hotkey that freezes, and then another hotkey with the same key to set the value


How would this script look?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 465

Joined: 09 May 2003
Posts: 25509
Location: The netherlands

PostPosted: Sat Mar 09, 2024 1:59 pm    Post subject: Reply with quote

just a normal address entry with 2 hotkeys assigned
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
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