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 


Maybe a 'stupid question'

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

Joined: 09 Mar 2015
Posts: 49

PostPosted: Sun Feb 25, 2018 9:25 am    Post subject: Maybe a 'stupid question' Reply with quote

After searching and trying I was able to make a very simple lua script for an aob swap Smile I got it to work, but not smooth... And it kinda confuses me, when I had those [enable] and disable parameters in the script it gave an error, now I just have the aobswap functions in a script .ct, but when i open that file to open cheat engine and find my process, it doesn't automatically run the script either. I'd just like the easiest way to use/activate my script. It looks complicated to me those different ways to use code like the auto assembler, .ct or .lua files, and how to make it autorun... The info I found about this didn't make it very clear for me.

So for now it only works when I manually put the aobswap codes in the 'show cheat table lua script', and execute...

Thanks for any help.
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 14

Joined: 24 Feb 2017
Posts: 441
Location: 'Merica

PostPosted: Sun Feb 25, 2018 9:35 am    Post subject: Reply with quote

May be this will help explain it:
CE Lua Basics

As for using Lua or CEA files (the easiest way), "require" for Lua and "include" for AA sections.

include
require

You could also use Lua's "dofile" to execute a Lua file.

But all Lua will need to start at the cheat table Lua script to be executed automatically (if the right options in the CE settings is set).

_________________
Back to top
View user's profile Send private message
Aylin
Expert Cheater
Reputation: 2

Joined: 16 Feb 2017
Posts: 154

PostPosted: Sun Feb 25, 2018 10:47 am    Post subject: Reply with quote

There's some complicated explanation. Wink
But if I understood correctly:
(But if I misunderstood; I'll wait clarify the description of the new. Wink )
Paste the following code into a .lua (edit it with notepad)
Then place the file in the Cheat engine Autorun Folder.
If you do not have a .lua file. Copy one from the Autorun folder,
Arrange it on the table.
Lua File Name: AobswapPlugin

(or create a different Autorun lua based on the example. Wink (What if you need))

Code:
function DEC_HEX(IN)
    local B,K,OUT,I,D=16,"0123456789ABCDEF","",0
   if IN<1 then
      OUT=0
      return OUT
   end
    while IN>0 do
        I=I+1
        IN,D=math.floor(IN/B),math.mod(IN,B)+1
        OUT=string.sub(K,D,D)..OUT
    end
    return OUT
end

function Aobswap(search, change)
   aobs = AOBScan(search)
   if(aobs ~= nil) then
      j = stringlist_getCount(aobs)
      --print("Found:",j);
      for i = 1, j do
         --print(stringlist_getString(aobs,i-1));
            --66 ?? ?? d1 a1 68 ?? ?? d0 d0
         address=stringlist_getString(aobs,i-1)
                for i = 1, string.len(change), 3 do
               z = string.sub(change, i, i+2)
                    x, y = string.find(z, "%?+")
                    if (x == nil) then
                  script=[[
                  ]]..address.."+"..(DEC_HEX((i-1)/3))..[[:
                  db ]]..z..[[
                  ]]
                  autoAssemble(script)
                  --print(z)
                        --print(address.."+"..(DEC_HEX((i-1)/3)))
                    end
                end
      end
      object_destroy(aobs);
      aobs=nil
   end
end

_________________
See Hitler ! This Trainer is for you!
http://forum.cheatengine.org/viewtopic.php?t=606786
Enthusiastic people: Always one step ahead!
Do not underestimate me Master: You were a beginner in the past!
Back to top
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater
Reputation: 17

Joined: 10 Apr 2015
Posts: 619

PostPosted: Sun Feb 25, 2018 5:47 pm    Post subject: Reply with quote

LtO
Quote:
...it doesn't automatically run the script either


Did you check CE setting : 'When a table has lua script, execute it' ?.
If setting is 'Never' then you must execute lua script manually every time open that CT.

Or

If your script contain a function, say AOB swap function, then you need trigger that function to execute it by call that function name.

_________________
Singapore Sling + Johnnie Walker + Some Peanuts....
Back to top
View user's profile Send private message
LtO
Cheater
Reputation: 0

Joined: 09 Mar 2015
Posts: 49

PostPosted: Wed Feb 28, 2018 5:38 am    Post subject: Reply with quote

Thanks, yes that checkbox is enabled... I had installed the aobswapplugin already and for now just execute the aobswaps in lua table... Not a problem also cuz i modify sometimes what I want to swap... But when I load the cheat table I made, it doesn't show the table in my cheat engine, only when i go to lua table script and have to execute it there too...
Back to top
View user's profile Send private message
Aylin
Expert Cheater
Reputation: 2

Joined: 16 Feb 2017
Posts: 154

PostPosted: Wed Feb 28, 2018 7:13 am    Post subject: Reply with quote

LtO wrote:
But when I load the cheat table I made, it doesn't show the table in my cheat engine, only when i go to lua table script and have to execute it there too...


We are living this too. For now this should not be a problem.
Besides, thanks for coming back and telling me about the situation.
Most people, after receiving the information, forgets to return to you. Wink

Code:
form_show(UDF1)


It looks like these commands do not work on CT startup.
Execute with "Execute Script" command.
This problem can also be caused by changes we have made in CE. Wink

_________________
See Hitler ! This Trainer is for you!
http://forum.cheatengine.org/viewtopic.php?t=606786
Enthusiastic people: Always one step ahead!
Do not underestimate me Master: You were a beginner in the past!
Back to top
View user's profile Send private message MSN Messenger
LtO
Cheater
Reputation: 0

Joined: 09 Mar 2015
Posts: 49

PostPosted: Thu Mar 01, 2018 7:43 am    Post subject: Reply with quote

Aylin wrote:
LtO wrote:
But when I load the cheat table I made, it doesn't show the table in my cheat engine, only when i go to lua table script and have to execute it there too...


We are living this too. For now this should not be a problem.
Besides, thanks for coming back and telling me about the situation.
Most people, after receiving the information, forgets to return to you. Wink

Code:
form_show(UDF1)


It looks like these commands do not work on CT startup.
Execute with "Execute Script" command.
This problem can also be caused by changes we have made in CE. Wink


Np, I think it's normal, I'm happy people help me here, so Thanks. On another forum I often get no response at all...
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater
Reputation: 17

Joined: 10 Apr 2015
Posts: 619

PostPosted: Thu Mar 01, 2018 8:30 am    Post subject: Reply with quote

Then, that is not a 'Stupid Question'..... Razz
_________________
Singapore Sling + Johnnie Walker + Some Peanuts....
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