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 


How to create a Hotkey in Lua that writes to address

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

Joined: 09 Jun 2015
Posts: 77

PostPosted: Fri Sep 02, 2016 10:01 pm    Post subject: How to create a Hotkey in Lua that writes to address Reply with quote

So, my code is 99.9% complete(and yours too, Zanzer. I included you in the credits.) 99% of the time my codes work, but sometimes a write occurs that cannot be taken back within a millisecond of time. Most of the time this will not happen, but when it does, I want it to be correctable. So, I want them to be able to press something like the A key, Alt Key, or an F# key. How would I write this? After this, the code is finished!
Back to top
View user's profile Send private message
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Fri Sep 02, 2016 10:46 pm    Post subject: Reply with quote

Why dont you have the code itself check if the write "took" by performing a read and writing it again if it didnt? Users shouldnt have to do the work themselves, they wanted you to do it, that is why they want to use your works!

If you are dead set on it, then:

Code:
function checkKeys(timer)
  if (isKeyPressed(VK_A)) then
      write_w/e(address,value)
  end

end

t=createTimer(nil)
timer_setInterval(t, 100)
timer_onTimer(t, checkKeys)
timer_setEnabled(t, true)
Back to top
View user's profile Send private message
Reclaimer Shawn
Advanced Cheater
Reputation: 0

Joined: 09 Jun 2015
Posts: 77

PostPosted: Fri Sep 02, 2016 11:07 pm    Post subject: Reply with quote

cooleko wrote:
Why dont you have the code itself check if the write "took" by performing a read and writing it again if it didnt? Users shouldnt have to do the work themselves, they wanted you to do it, that is why they want to use your works!

If you are dead set on it, then:

Code:
function checkKeys(timer)
  if (isKeyPressed(VK_A)) then
      write_w/e(address,value)
  end

end

t=createTimer(nil)
timer_setInterval(t, 100)
timer_onTimer(t, checkKeys)
timer_setEnabled(t, true)


Now, for all of my writes I've had to use writeBytes as the entire game is in Big Endian format. The only reason I'm using this is because freezing the address is not viable. It has to do with health values, but those are also directly related with battle termination. If it continously went, the battle never ends. But, if it doesn't the value doesn't sync. And I can't see how many times the value gets written to via ASM because the game is in PPC. See my dilemmas? I really appreciate the help though! So, how would I use this with the writeBytes function?
Back to top
View user's profile Send private message
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Fri Sep 02, 2016 11:30 pm    Post subject: Reply with quote

replace writes_w/e with writeBytes
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Fri Sep 02, 2016 11:31 pm    Post subject: Reply with quote

Code:
if health_hotkey ~= nil then
  health_hotkey.destroy()
end
health_hotkey = createHotkey(function()
  writeBytes("address", bytes)
end, VK_A)
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