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 script for 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: Sun Jul 02, 2023 4:03 pm    Post subject: lua script for trainer Reply with quote

there is a table with the assembler code
, click on the cross, enter a number and everything works well, how to implement the same, but in the form of a trainer, enter a number and everything works?
address:playerAggro (02390011)
here is the code
Code:

define(address, Terraria.Player::ResetEffects+293)
define(bytes, 89 96 2C 03 00 00)

[ENABLE]

assert(address, bytes)

alloc(newmem, 1)

label(code)
label(return)
label(playerAggro)

registersymbol(playerAggro)

newmem:
code:
  fild dword ptr [playerAggro]
  fistp dword ptr [esi+32C]
  jmp return

  playerAggro:
    dd (int)0

address:
  jmp newmem
  nop
return:

[DISABLE]

address:
  db bytes
  //mov [esi+328],edx

unregistersymbol(*)
dealloc(*)

thanks to those who tried to help earlier (couldn't answer), but all the methods didn't work, maybe I somehow described my problem wrong, or I'm too stupid to understand something
(I even tried to find a pointer, but even here a failure)



hm.png
 Description:
 Filesize:  3.14 KB
 Viewed:  3291 Time(s)

hm.png


Back to top
View user's profile Send private message
Starter_But
Advanced Cheater
Reputation: 0

Joined: 26 Oct 2021
Posts: 53

PostPosted: Mon Jul 03, 2023 4:10 am    Post subject: Reply with quote

No help needed, I was able to do it
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Mon Jul 03, 2023 4:45 am    Post subject: Reply with quote

The least you could do is post the solution so that if others do happen to come across the same problem then they will find the answer.
Back to top
View user's profile Send private message
Starter_But
Advanced Cheater
Reputation: 0

Joined: 26 Oct 2021
Posts: 53

PostPosted: Mon Jul 03, 2023 9:52 am    Post subject: Reply with quote

Code:

local scriptAggro=[[define(address, Terraria.Player::ResetEffects+293)
define(bytes, 89 96 2C 03 00 00)

[ENABLE]

assert(address, bytes)

alloc(newmem, 1)

label(code)
label(return)
label(playerAggro)

registersymbol(playerAggro)

newmem:
code:
  fild dword ptr [playerAggro]
  fistp dword ptr [esi+32C]
  jmp return

  playerAggro:
    dd (int)0

address:
  jmp newmem
  nop
return:

[DISABLE]

address:
  db bytes
  //mov [esi+328],edx

unregistersymbol(*)
dealloc(*)]]

in order to enter any value, we need to hook out our address, we register playerAggro in the assembler code, which means that in the furthest solution we will take information from it,
create a script on and off
Code:

if CETrainer.rPlayerMobsAgro.Checked then
            local r
            local originalBytes=nil

            r,originalBytes=autoAssemble(scriptAggro)
            if not r then
               CETrainer.rPlayerMobsAgro.Checked=false
            end
            else
            if originalBytes then
               autoAssemble(scriptAggro,originalBytes)
               originalBytes=nil
            end
         end

Now, to specify the value we want, it's enough just to add getting an address to the code inclusion section.
Code:

if CETrainer.rPlayerMobsAgro.Checked then
            local r
            local originalBytes=nil
            r,originalBytes=autoAssemble(scriptAggro)
            tests = string.format('%08X', getAddress('playerAggro'))
            valueAggro=tonumber(CETrainer.AgroEf.Text)
            writeInteger(tests,valueAggro)

            if not r then
               CETrainer.rPlayerMobsAgro.Checked=false
            end
            else
            if originalBytes then
               autoAssemble(scriptAggro,originalBytes)
               originalBytes=nil
            end
            end

I'm not very good at lua, if I accidentally made a mistake somewhere, then please correct
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Mon Jul 03, 2023 12:52 pm    Post subject: Reply with quote

It's perfectly fine although I don't think any auto assembly is required. This is wholly achievable with Lua. What's important is it works how you intended. Also, thanks for posting the solution for others to see.
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