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 


Sideloading data from file

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3312

PostPosted: Sat May 31, 2025 3:52 am    Post subject: Sideloading data from file Reply with quote

Hello LUA Masters!

I would like to save data next to the CT file, in a (preferably) text-based file, load the data from the file whenever the user enables the script and save it whenever the user changes some variable.

INI files come to mind and I found https://github.com/Dynodzzo/Lua_INI_Parser so I am thinking about using that.
If there are better practices, please let me know!

Anyhow, what I would like to understand is how does one locate the file.
- Is there a property for "my cheat table" so the memoryrecord could find out its own CT path?
- Is there a "last opened" somewhere?
- Is there a call to get the name of the CT file?

Thank you!


Last edited by Csimbi on Sat May 31, 2025 8:08 am; edited 1 time in total
Back to top
View user's profile Send private message  
AylinCE
Grandmaster Cheater Supreme
Reputation: 36

Joined: 16 Feb 2017
Posts: 1499

PostPosted: Sat May 31, 2025 7:41 am    Post subject: Reply with quote

Which of these solutions approaches the problem?

Get the name or path of the opened table (.CT):
( autorun lua code ..)
Code:
mf = getMainForm()

if titleTmr then titleTmr.Destroy() titleTmr=nil end
titleTmr = createTimer(mf)
titleTmr.Interval = 2000

titleTmr.OnTimer=function()
title = mf.SaveDialog1 or mf.OpenDialog1 or nil
filefullpath = title.Filename
pathCut = extractFileName(filefullpath)

 if filefullpath then
    print(filefullpath)
    print(pathCut)
    -- load codes
 else
    print("no title or: " .. mf.caption)
 end
titleTmr.Destroy()
end

titleTmr.Enabled=true


Edit, save or replace:
https://forum.cheatengine.org/viewtopic.php?p=5778791#5778791

I think I deserve a little more explanation. Smile

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
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 Visit poster's website MSN Messenger 
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3312

PostPosted: Sat May 31, 2025 8:06 am    Post subject: Reply with quote

AylinCE wrote:

...

Much obliged, thank you!

I cut out the timer code and I used this:
Code:
mf = getMainForm()

title = mf.SaveDialog1 or mf.OpenDialog1 or nil
filefullpath = title.Filename
pathCut = extractFileName(filefullpath)

 if filefullpath then
    print(filefullpath)
    print(pathCut)
    -- load codes
 else
    print("no title or: " .. mf.caption)
 end

Works great, thanks!
Back to top
View user's profile Send private message  
AylinCE
Grandmaster Cheater Supreme
Reputation: 36

Joined: 16 Feb 2017
Posts: 1499

PostPosted: Sat May 31, 2025 9:59 am    Post subject: Reply with quote

If you are going to use the code with the lua package in the autorun folder, you need to start it with a delay to get the correct result.

If the delay is set to 2-3 seconds with the timer, the program (CT) will not conflict with the loading process and will find a stable reading area.

Also, if you are thinking of using the code globally, you can visit the link below and consider the solution that makes it suitable for "OneDrive" or ASCII characters.

https://forum.cheatengine.org/viewtopic.php?p=5793327#5793327

...

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
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 Visit poster's website MSN Messenger 
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3312

PostPosted: Sat May 31, 2025 11:34 am    Post subject: Reply with quote

Now you are trying to spoil me Wink
Local files are good enough for me.
I actually got it working.
Full autoload when script is enabled and autosave when settings I interested in change.
Playtesting it now.
Thanks!
Back to top
View user's profile Send private message  
AylinCE
Grandmaster Cheater Supreme
Reputation: 36

Joined: 16 Feb 2017
Posts: 1499

PostPosted: Sat May 31, 2025 1:35 pm    Post subject: Reply with quote

Ahh, if the code is currently doing a sufficient job, that's fine.

Ignore this, I'm just observing the details out loud.. Smile

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
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 Visit poster's website MSN Messenger 
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