|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Mon Jan 09, 2017 11:17 pm Post subject: Save / Load Trainer Class Properties (again) |
|
|
Since no response for my other topic : http://forum.cheatengine.org/viewtopic.php?t=602429
Code: | UDF1.DoNotSaveInTable=false
UDF1.show()
UDF2.hide()
function CEButton1Click(sender)
UDF2.show()
return
end
settings=getSettings('mytrainerstuff')
old_label=settings.Value[UDF1.CELabel1] --- get old Label properties
UDF1.CELabel1.Caption = old_label
fn = getProperty(UDF1.CELabel1, "Font")
fn_name = getProperty(UDF1.CELabel1.Font, "Name")
fn_color = getProperty(UDF1.CELabel1.Font, "Color")
fn_height = getProperty(UDF1.CELabel1.Font, "Height")
UDF2.CEEdit1.Text = old_label
print(fn_name)
print(fn_color)
print(fn_height)
function DynamicLabel_Ttl()
new_label = UDF2.CEEdit1.Text
UDF1.CELabel1.Caption = new_label ---- get Caption from Edit Box
--------------------- // also set font color, style, name and height defined by user
end
UDF2.CEEdit1.OnChange = DynamicLabel_Ttl
function reset()
UDF1.CELabel1.Caption = old_label
UDF2.CEEdit1.Text = old_label
end
function saveChange()
settings.Value[UDF1.CELabel1]=new_label
------------------- // also save all font properties has given by user (font name, style, color, etc)
------------------- How... to save it all and load in next open the trainer
showMessage("Done. Go to CE MENU and save as SAVE AS")
return
UDF2.hide()
end
UDF2.CEButton1.onClick = reset
UDF2.CEButton2.onClick = saveChange
form_onClose(UDF1, FormClose)
UDF1.Show()
|
Script above : If only save CELabel1.Caption to getSettings('mytrainerstuff'), not give problem when load setting.Value for next opening trainer / CT file. But if adding CELabel1 font properties,
it give problem as shown by notes on script above.
How to save last class properties (color, style, height, caption, value, etc)
for CELabel, CEPanel, CEButton for load and use on next opening trainer ?
Rgds
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Tue Jan 10, 2017 1:13 am Post subject: |
|
|
There is currently no way to edit and save a form's data with lua
But after loading the table you can edit the properties of the class.
as for your code:
Code: |
settings.Value[UDF1.CELabel1]
|
should be
Code: |
settings.Value['UDF1.CELabel1']
|
_________________
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 |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Tue Jan 10, 2017 8:26 am Post subject: |
|
|
DB wrote :
Quote: | settings.Value['UDF1.CELabel1'] |
Done. Fixed.
Anyway, I am use text file to store variables and class properties. It work fine and just need implements it to my project.
Example :
Code: | UDF1.Show()
UDF2.Hide()
local function tmerge(t,o,...)
for k,v in pairs(o) do
t[k]=v end
if select('#',...)>0 then
return tmerge(t,...)
else
return t
end
end
--------------- Define Last Variable for UDI1 Classes
function getLastVar()
local f = assert(io.open("TrainerStuffs.txt", "r"))
lb_cap_old = f:read("*line")
lb_fnm_old = f:read("*line")
lb_fcl_old = f:read("*line")
lb_fst_old = f:read("*line")
lb_hgt_old = f:read("*line")
pn_clr_old = f:read("*line")
f:close()
UDF1.CELabel1.Caption = lb_cap_old
local fn = UDF1.CELabel1.Font
tmerge(fn,{Name=lb_fnm_old,Color=lb_fcl_old,Style=lb_fst_old,Height=lb_hgt_old})
UDF1.CEPanel1.Color = pn_clr_old
end
function file_exists(file)
local f = io.open(file, "rb")
if f then f:close() end
return f ~= nil
end
function checkIt(file)
if not file_exists(file) then
showMessage("Can't find TrainerStuffs.txt. Trainer properties set to last saved")
return
else
getLastVar()
end
end
local file = "TrainerStuffs.txt"
local sure = checkIt(file)
function setter()
UDF2.Show()
end
function DynamicLabel_Ttl()
new_label = UDF2.CEEdit1.Text
UDF1.CELabel1.Caption = new_label
local fnt = UDF1.CELabel1.Font
tmerge(fnt,{Color=0xffffff,Name='Arial',Height=24,Style='[bsBold]'})
UDF1.CEPanel1.Color = 69659660
end
-------------- Save classes var to a txt file
function saveChanges()
lb_cap = UDF1.CELabel1.Caption
lb_fnm = UDF1.CELabel1.Font.Name
lb_fcl = UDF1.CELabel1.Font.Color
lb_fst = UDF1.CELabel1.Font.Style
lb_hgt = UDF1.CELabel1.Font.Height
pn_clr = UDF1.CEPanel1.Color
local f = assert(io.open("TrainerStuffs.txt", "w"))
f:write(lb_cap, "\n")
f:write(lb_fnm, "\n")
f:write(lb_fcl, "\n")
f:write(lb_fst, "\n")
f:write(lb_hgt, "\n")
f:write(pn_clr, "\n")
f:close()
showMessage("Done. File save to 'TrainerStuffs.txt'. Make sure this file together with your trainer")
end
function resetter()
UDF1.CELabel1.Caption = lb_cap_old
local fn1 = UDF1.CELabel1.Font
tmerge(fn1,{Name=lb_fnm_old,Color=lb_fcl_old,Style=lb_fst_old,Height=lb_hgt_old})
UDF1.CEPanel1.Color = pn_clr_old
UDF2.CEEdit1.Text = lb_cap_old
end
function backtoUDF1()
UDF1.Show()
UDF2.Hide()
end
function exitTrainer()
form_hide(UDF1)
closeCE()
return caFree
end
UDF1.CEButton1.onClick = setter
UDF2.CEEdit1.OnChange = DynamicLabel_Ttl
UDF2.CEButton1.onClick = saveChanges
UDF2.CEButton2.onClick = resetter
UDF2.CEButton3.onClick = backtoUDF1
form_onClose(UDF1, exitTrainer) |
Thanks and regard
|
|
Back to top |
|
|
|
|
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
|
|