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 


getting trainer path with name

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

Joined: 29 Mar 2021
Posts: 64

PostPosted: Thu Jul 22, 2021 1:13 am    Post subject: getting trainer path with name Reply with quote

how do i get the current trainer path with its name? i know you can get the directory with TrainerOrigin but i also want to get the trainer name.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Jul 22, 2021 2:51 am    Post subject: Reply with quote

Code:

return (TrainerOrigin or getCheatEngineDir()) .. enumModules(getCheatEngineProcessID())[1].Name

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

Joined: 29 Mar 2021
Posts: 64

PostPosted: Thu Jul 22, 2021 4:09 am    Post subject: Reply with quote

everytime i use it i only get cheatengine-x86_64-SSE4-AVX2.exe, is there no other way to get the current trainer/ct's file name? e.g. Test.CT or etc.
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Thu Jul 22, 2021 11:11 am    Post subject: Reply with quote

mgr.inz.Player wrote:

--( https://forum.cheatengine.org/viewtopic.php?t=593741 )
Code:
local mf = getMainForm()
local sd = mf.SaveDialog1
local od = mf.OpenDialog1
local filefullpath
local filename
local mi

local function returnFileName(path)
 --extracts file name from full path (not full path => return nil)
 return (path~=nil) and (path:match("\\([^\\]+)$"))
end

  if filename then currentTableNameLabel.Caption = 'CT Name: '..filename
              else currentTableNameLabel.Caption = 'CT Name:' end


In your case the code could be used like this;

(We assume that you will save the Trainer or ".CT" at least once and use it in the registered table)

Code:
function FileName(opsion)
local filename=""
opsion=tonumber(opsion)
mf = getMainForm()
local sd = mf.SaveDialog1
local od = mf.OpenDialog1

local function returnFileName(path)
 return (path~=nil) and (path:match("\\([^\\]+)$"))
end

filefullpath = sd.Filename or od.Filename or ''
  if opsion==1 then filename = filefullpath
  else
  filename = returnFileName(filefullpath)
  end
  return filename
end

local CTName=FileName(1) --full path + name
print(CTName)

local CTName1=FileName(2) --name
print(CTName1)
Back to top
View user's profile Send private message
HexaG0n
Advanced Cheater
Reputation: 0

Joined: 29 Mar 2021
Posts: 64

PostPosted: Fri Jul 23, 2021 1:10 am    Post subject: Reply with quote

thank you so much ByTransient, this is exactly what im looking for! Very Happy

edit: when i open the ct, for some reason it doesnt give me the path name unless i execute the script again. am i doing something wrong?
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Fri Jul 23, 2021 4:23 am    Post subject: Reply with quote

HexaG0n wrote:

edit: for some reason it doesnt give me the path name unless i execute the script again.


Codes don't work without a trigger or run.

If I did not make a wrong translation, I can answer the problem with 1 solution. But this path will be resolved in CE Autorun folder, not in CT file.

You can browse @mgr.inz.Player's code and paste the plugin into CE>>Autorun folder. So when you open the CT, you can always see the CT name above the "Found list" on the CE Main Form.

( https://forum.cheatengine.org/viewtopic.php?t=593741 )

However, I don't understand why you want to know the CT file that you already know the name and opened.

If you are considering using this code in Trainer, I can give you better idea.
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