View previous topic :: View next topic |
Author |
Message |
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1262
|
Posted: Tue Feb 13, 2024 10:55 am Post subject: Error printing trainer name! |
|
|
@DarkByte, the code below works fine with ".CT".
However, when I try it with ".CETRAINER", it gives a loading error for the table and the Trainer does not open.
What I'm trying to do is get the filename of the current Trainer (cetrainer).
I would appreciate it if you could please try it and give me some advice. Thanks.
Code: | if form11 then form11.destroy() form11=nil end
form11 = createForm()
form11.Position = poDesktopCenter
form11.Popupmode = 0
form11.Width = 320
form11.Height = 240
form11.ShowInTaskBar="stAlways"
mf23 = MainForm
local sd2, od2 = mf23.SaveDialog1, mf23.OpenDialog1
filefullpath = sd2.Filename or od2.Filename or ""
if filefullpath~=nil or filefullpath~="" then
print("filefullpath-1: "..filefullpath)
else
saveTable()
sd2 = mf23.SaveDialog1
filefullpath = sd2.Filename
print("filefullpath-1: "..filefullpath)
end
|
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25301 Location: The netherlands
|
Posted: Tue Feb 13, 2024 11:22 am Post subject: |
|
|
use the variable TrainerOrigin to get the path of the .cetrainer
_________________
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 |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1262
|
Posted: Tue Feb 13, 2024 11:45 am Post subject: |
|
|
No. What I want is the Trainer filename.
"TrainerOrigin" gives the file path where the Trainer is registered.
If there is more than one Trainer in the folder, it is difficult to find the Trainer name used.
EDITING :
I apologize. There is something I missed.
When I left a delayed trigger (Timer) everything worked fine.
I am sharing the code for archive purposes:
Code snippet that corrects the Trainer name at every startup;
Code: | if form11 then form11.destroy() form11=nil end
form11 = createForm()
form11.Position = poDesktopCenter
form11.Popupmode = 0
form11.Width = 320
form11.Height = 240
form11.ShowInTaskBar="stAlways"
function EditTrainerName(newName)
saveTable()
mf23 = getMainForm()
sd2 = mf23.SaveDialog1
od2 = mf23.OpenDialog1
sd2.DefaultExt = ".cetrainer" or ".CETRAINER"
filefullpath = sd2.FileName or od2.FileName
local filename = ""
local testCheck1 = 0
ttName1=createTimer(MainForm) ttName1.Interval=2000
local function returnFileName(path,ops)
local restt1 = ""
if ops==1 then
restt1 = path:match("\\([^\\]+)$")
elseif ops==2 then
restt1 = path:match("(.*)\\")
end
return restt1
end
ttName1.OnTimer=function()
saveTable()
filefullpath = sd2.FileName or od2.FileName
--print("filefullpath-2: "..filefullpath)
path = returnFileName(filefullpath,2) -- or path = TrainerOrigin
path = path.."\\"
--print("path-2: "..path)
filename = returnFileName(filefullpath,1)
--print("filename: "..filename)
if filename~=newName then
os.rename(path..filename, path..newName)
testCheck1 = 1
end
if testCheck1==1 then
ttName1.Enabled=false
nm1 = newName:match("(.*)%.")
showMessage([[Trainer has been updated to the "]]..nm1..[[" version!]])
else
ttName1.Enabled=false
end
end
ttName1.Enabled=true
end
form11.OnClose=function()
closeCE()
return cafree
end
-- use
EditTrainerName("myGameTrainer-V002.cetrainer") |
_________________
|
|
Back to top |
|
|
|