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 


Lua code for the cheat engine trainer

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

Joined: 26 Oct 2021
Posts: 53

PostPosted: Sat Jul 01, 2023 2:47 am    Post subject: Lua code for the cheat engine trainer Reply with quote

Hello, there is an assembler code that works correctly when activated
Code:

define(address, Terraria.NPC::StrikeNPC+724)
define(bytes, 29 86 0C 01 00 00)
 
[ENABLE]
 
assert(address, bytes)
 
alloc(newmem, 1)
 
label(code)
label(return)
 
newmem:
code:
sub [esi+10C],#999999
jmp return
 
address:
jmp newmem
nop
return:
 
[DISABLE]
 
address:
db bytes
//sub [esi+10C],eax
 
dealloc(*)

Using this code, I decided to create a trainer, the code for which will be activated by the checkbox
Code:

local address = "Terraria.NPC::StrikeNPC+724"
local bytes = "29 86 0C 01 00 00"
local originalBytes = readBytes(address, #bytes)
 
function enable()
    writeBytes(address, bytes)
end
 
function disable()
    writeBytes(address, originalBytes)
end
 
if CETrainer.rPlayerOneHit.Checked then
    enable()
else
    disable()

But for some reason, when activating this code, nothing happens or the code works differently, what did I do wrong in the lua code?
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Sat Jul 01, 2023 3:00 am    Post subject: This post has 1 review(s) Reply with quote

Code:
local origBytes
local sOnEnable = [[
globalalloc(rPlayerOneHit, 40)

rPlayerOneHit:
sub [esi+10C], #999999
jmp return

"Terraria.NPC::StrikeNPC"+724:
jmp rPlayerOneHit
nop
return:
]]

local sOnDisable = [[
dealloc(rPlayerOneHit)
unregisterSymbol(rPlayerOneHit)
]]

if CETrainer.rPlayerOneHit.Checked then
  origBytes =  readBytes("Terraria.NPC::StrikeNPC+724", 6)
  autoAssemble(sOnEnable)
else
  autoAssemble(sOnDisable)
  writeBytes("Terraria.NPC::StrikeNPC+724", origBytes)
end

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
Starter_But
Advanced Cheater
Reputation: 0

Joined: 26 Oct 2021
Posts: 53

PostPosted: Sat Jul 01, 2023 3:16 am    Post subject: Reply with quote

Frouk wrote:
Code:

globalalloc(rPlayerOneHit, 40)

Thank you, but why did you take 40?
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