View previous topic :: View next topic |
Author |
Message |
poppyko How do I cheat? Reputation: 0
Joined: 05 Sep 2021 Posts: 2
|
Posted: Sun Sep 05, 2021 6:47 am Post subject: Lua script for check if the file exists.[solved] |
|
|
I want to check if a certain file(setting.txt) is exist when I run an exe, but I can't run it correctly.
The script looks like this.
What I want to do :if there is a setting.txt file, start it, if not, bring up a dialog and exit.
It works fine with the execute script on cheatengine, but not with the standalone exe.
Code: | --TRAINERGENERATORSTART--
--hideAllCEWindows()
function file_check(file_name)
local file_found=io.open(file_name, "r")
if file_found==nil then
file_found=file_name .. " ... Error - setting file missing"
closeCE()
else
file_found=file_name .. " ... found"
end
return file_found
end
print(file_check("setting.txt"))
RequiredCEVersion=7.3
if (getCEVersion==nil) or (getCEVersion()<RequiredCEVersion) then
messageDialog('Please install Cheat Engine '..RequiredCEVersion, mtError, mbOK)
closeCE()
end
function onPostHotkey0(Hotkey)
--Executed after the "toggle*" cheat got executed
local memrec=Hotkey.Owner
local isActive=memrec.Active --get the state after the hotkey got triggered
CETrainer.CHEAT0.setActive(isActive) --gui update, nothing else
if gPlaySoundOnAction then
if isActive then
playSound(gActivateSound)
else
playSound(gDeactivateSound)
end
end
end |
Last edited by poppyko on Sun Sep 05, 2021 8:30 am; edited 1 time in total |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Sun Sep 05, 2021 7:00 am Post subject: |
|
|
Where is the file located? Inside the trainer package or next to the trainer exe ?
if inside the trainer package use getCheatEngineDir. if next to tbe trainer exe, use TrainerOrigin
_________________
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 |
|
|
poppyko How do I cheat? Reputation: 0
Joined: 05 Sep 2021 Posts: 2
|
Posted: Sun Sep 05, 2021 8:29 am Post subject: |
|
|
Yes, it is in the same folder as trainer.exe, so I was able to solve the problem by using TrainerOrigin.
Thank you for your quick answer!
I sleep well.
|
|
Back to top |
|
|
|