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 


incorrect operation of the script

 
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 4:08 am    Post subject: incorrect operation of the script Reply with quote

work code
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(*)

code on lua
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

when turned off, the code does not work correctly
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sat Jul 01, 2023 4:38 am    Post subject: Reply with quote

try
Code:

local script=[[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(*)]]

if CETrainer.rPlayerOneHit.Checked then
  local r
  discript12345=nil --not local for a reason

  r,discript12345=autoAssemble(script)
  if not r then
    CETrainer.rPlayerOneHit.Checked=false
  end
else
  if discript12345 then
    autoAssemble(script,discript12345)
    discript12345=nil
  end
end


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

Joined: 26 Oct 2021
Posts: 53

PostPosted: Sat Jul 01, 2023 9:13 am    Post subject: Reply with quote

thank you very much, everything is working now
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