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 


[Help] extra files don't work in exe trainer

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Centos
How do I cheat?
Reputation: 0

Joined: 07 Mar 2022
Posts: 9

PostPosted: Wed Jul 06, 2022 6:28 am    Post subject: [Help] extra files don't work in exe trainer Reply with quote

I have one .h file and another .bin file attached to a table and they both work fine as part of a ct file.

Then I put them in the Include folder and added this folder during exe generation as extra files and set the path with getCheatEngineDir() at the beginning of the table. They are both appearing in the appropriate folder under the temp folder when the trainer is launched, but none of the functions using these 2 files is working.

Here is my code of adding the path

{$lua}
if syntaxcheck then return end
path = getCheatEngineDir()
addCIncludePath(path .. 'include\\abc.h')
addCIncludePath(path .. 'include\\abc.bin')
[ENABLE]
blah blah...

Did I miss something? Please help me.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Wed Jul 06, 2022 8:35 am    Post subject: Reply with quote

addCIncludePath needs the path, no the filepath. So just \\include
_________________
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
Centos
How do I cheat?
Reputation: 0

Joined: 07 Mar 2022
Posts: 9

PostPosted: Wed Jul 06, 2022 7:02 pm    Post subject: Reply with quote

Dark Byte wrote:
addCIncludePath needs the path, no the filepath. So just \\include


I changed it to

{$lua}
if syntaxcheck then return end
path = getCheatEngineDir()
addCIncludePath(path .. '\\include')

[ENABLE]
blah blah...

still no luck Sad
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Jul 07, 2022 4:47 am    Post subject: Reply with quote

try `addCIncludePath(path .. 'include\\')` instead

also, how do you reference the included files ?

_________________
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
Centos
How do I cheat?
Reputation: 0

Joined: 07 Mar 2022
Posts: 9

PostPosted: Fri Jul 08, 2022 11:00 pm    Post subject: Reply with quote

Dark Byte wrote:
try `addCIncludePath(path .. 'include\\')` instead

also, how do you reference the included files ?


It looks like this:

Code:
{$lua}
if syntaxcheck then return end
local HeaderFile = findTableFile("abc.h")
if (HeaderFile ~= nil) then HeaderFile.saveToFile("abc.h") end
local Meta = findTableFile("abc.bin")
if (Meta ~= nil) then
    local mem = allocateMemory(Meta.Stream.Size)
    local data = readBytesLocal(Meta.Stream.Memory, Meta.Stream.Size, true)
    writeBytes(mem, data)
    registerSymbol("AnyName", mem, true)
else
    registerSymbol("AnyName", 0, true)
end


And in the other code blocks, just #include "abc.h" if neccessary
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Fri Jul 08, 2022 11:54 pm    Post subject: Reply with quote

try saveToFile(getCheatEngineDir().."abc.h") as the working path may be different in trainers

also, you don't even have to write to disk. You can emit the content of the include file into the AA script
Code:

{$lua}
local tf=findTableFile("abc.h")
local ss=createStringStream()
ss.copyFrom(tf.Stream,tf.Stream.Size)
local r=[[{$c}
]]
r=r..ss.DataString..[[

]] --needed
r=r..'{$asm}' --there's a reason I don't use the format parameter
ss.destroy()

--print(r)
return r
{$asm}

//the rest of your aa script, and do not use #include "abc.h"





---offtopic---

Also,
Code:

    local mem = allocateMemory(Meta.Stream.Size)
    local data = readBytesLocal(Meta.Stream.Memory, Meta.Stream.Size, true)
    writeBytes(mem, data)
    registerSymbol("AnyName", mem, true)

can be rewritten as:
Code:

    local mem=copyMemory(tf.stream.Memory, tf.stream.Size, nil, 2) --2=copy from CE to target
    registerSymbol("AnyName", mem, true)

_________________
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
Centos
How do I cheat?
Reputation: 0

Joined: 07 Mar 2022
Posts: 9

PostPosted: Sun Jul 10, 2022 4:21 am    Post subject: Reply with quote

Thank you! I will try it later. Very Happy
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