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 


Help | Save and load

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

Joined: 29 May 2019
Posts: 36

PostPosted: Wed Sep 20, 2023 11:02 am    Post subject: Help | Save and load Reply with quote

I made a Trainer using Cheat Engine,

Now in Trainer I have many checkboxes,

I would appreciate help on how to save and load the checkboxes
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1522

PostPosted: Thu Sep 21, 2023 12:37 am    Post subject: Reply with quote

I'm just asking to understand;
Do you want to save the final version of the checkboxes (Checked=true or false) when the trainer closes and load it when it opens?

If this is true, how many checkboxes do you have?
Too many checkboxes create long lists for "Save" and "Load".
Long list or collecting them all in one table depends on the options.

EDIT:

Code:
DP1=getScreenDPI()/96
expForm1=createForm()
expForm1.height=199*DP1 expForm1.width=312*DP1 expForm1.left=261*DP1 expForm1.top=98*DP1
expForm1.PopupMode=0 expForm1.caption="Test Check Box - Checked"
expForm1.Position="poDesktopCenter" expForm1.BorderStyle="bsSingle"  expForm1.ShowInTaskBar="stAlways"
-------------------------
----------------------- expForm1.CBox1 ----- 
expForm1.CBox1=createCheckBox(expForm1)
expForm1.CBox1.AutoSize=false
expForm1.CBox1.Name="CBox1"
expForm1.CBox1.height=23*DP1 expForm1.CBox1.width=90*DP1 expForm1.CBox1.left=29*DP1 expForm1.CBox1.top=30*DP1
expForm1.CBox1.caption="CBox1"
expForm1.CBox1.alignment="taRightJustify"
expForm1.CBox1.Font.Style="fsBold" expForm1.CBox1.Font.Size=0*DP1
-----------------------
----------------------- expForm1.CBox2 ----- 
expForm1.CBox2=createCheckBox(expForm1)
expForm1.CBox2.AutoSize=false
expForm1.CBox2.Name="CBox2"
expForm1.CBox2.height=23*DP1 expForm1.CBox2.width=90*DP1 expForm1.CBox2.left=29*DP1 expForm1.CBox2.top=60*DP1
expForm1.CBox2.caption="CBox2"
expForm1.CBox2.alignment="taRightJustify"
expForm1.CBox2.Font.Style="fsBold" expForm1.CBox2.Font.Size=0*DP1
-----------------------
----------------------- expForm1.CBox3 ----- 
expForm1.CBox3=createCheckBox(expForm1)
expForm1.CBox3.AutoSize=false
expForm1.CBox3.Name="CBox3"
expForm1.CBox3.height=23*DP1 expForm1.CBox3.width=90*DP1 expForm1.CBox3.left=29*DP1 expForm1.CBox3.top=90*DP1
expForm1.CBox3.caption="CBox3"
expForm1.CBox3.alignment="taRightJustify"
expForm1.CBox3.Font.Style="fsBold" expForm1.CBox3.Font.Size=0*DP1
-----------------------
----------------------- expForm1.CBox4 ----- 
expForm1.CBox4=createCheckBox(expForm1)
expForm1.CBox4.Name="CBox4"
expForm1.CBox4.AutoSize=false
expForm1.CBox4.height=23*DP1 expForm1.CBox4.width=90*DP1 expForm1.CBox4.left=29*DP1 expForm1.CBox4.top=120*DP1
expForm1.CBox4.caption="CBox4"
expForm1.CBox4.alignment="taRightJustify"
expForm1.CBox4.Font.Style="fsBold" expForm1.CBox4.Font.Size=0*DP1
-----------------------
----------------------- expForm1.CBox5 ----- 
expForm1.CBox5=createCheckBox(expForm1)
expForm1.CBox5.AutoSize=false
expForm1.CBox5.Name="CBox5"
expForm1.CBox5.height=23*DP1 expForm1.CBox5.width=90*DP1 expForm1.CBox5.left=29*DP1 expForm1.CBox5.top=150*DP1
expForm1.CBox5.caption="CBox5"
expForm1.CBox5.alignment="taRightJustify"
expForm1.CBox5.Font.Style="fsBold" expForm1.CBox5.Font.Size=0*DP1
-----------------------

local chck1=getSettings('cboxcheckeds')
local cbox_index = 0

 for i = 0, expForm1.ComponentCount - 1 do -- expForm1 = your trainer name (UDF1) , (CETrainer) ?
  c1 = (expForm1.Component[i].Name):sub(1,4) -- name = CECheckbox (sub(1,10))
   if c1=="CBox" then -- "CBox" = your CheckBox name (CECheckbox (sub(1,10)))
    cbox_index = tonumber(cbox_index) + 1
   end
 end

function saveCheckeds()
  for i=1, cbox_index do
    chck1.Value["CBox"..i]=expForm1["CBox"..i].Checked  -- (expForm1)"CBox" = your CheckBox name (CECheckbox) ?
   --print(chck1.Value["CBox"..i])
  end
end

function loadCheckeds()
  for i=1, cbox_index do
   res1 = chck1.Value["CBox"..i]
   res2 = false
   if res1=="0" then res2=false else res2=true end
   expForm1["CBox"..i].Checked = res2
   --print(chck1.Value["CBox"..i])
  end
end

expForm1.OnClose=function()
 saveCheckeds()
 expForm1.Destroy()
end

loadCheckeds()

_________________
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