View previous topic :: View next topic |
Author |
Message |
Razi Expert Cheater Reputation: 1
Joined: 17 Jan 2018 Posts: 202
|
Posted: Fri Oct 25, 2019 2:50 am Post subject: Can the menu items remember the previous checked state? |
|
|
Can the menu items remember the previous checked state at the next start of the standalone trainer? So that you don’t have to click menu item every time the trainer starts and trainer can read values from different addresses by default. Menu items: AutoCheck set to true and RadioItem set to true.
Code: | MenuIt = {}
for x = 15, 19 do
MenuIt[x] = UDF1["MenuItem"..x]
end
if MenuIt[15].Checked == true then
baseaddr = 0x400000
elseif MenuIt[16].Checked == true then
baseaddr = 0x50B980
elseif MenuIt[17].Checked == true then
baseaddr = 0x53F680
elseif MenuIt[18].Checked == true then
baseaddr = 0x6D9120
elseif MenuIt[19].Checked == true then
baseaddr = 0x936000
end |
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Fri Oct 25, 2019 3:18 am Post subject: |
|
|
You have to save the state somewhere and load it back later
e.g
Code: |
local settings=getSettings('mytrainer')
settings.Value['selecteditem']=123
settings.destroy()
|
and then load it back using something like
Code: |
local settings=getSettings('mytrainer')
local nr=settings.Value['selecteditem']
MenuIt[nr].Checked=true
|
_________________
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 |
|
|
Razi Expert Cheater Reputation: 1
Joined: 17 Jan 2018 Posts: 202
|
Posted: Fri Oct 25, 2019 12:53 pm Post subject: |
|
|
Tried, but it didn't work. Can you show a working example?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Fri Oct 25, 2019 4:54 pm Post subject: |
|
|
Did you confirm the value saved and loaded was what you set it to?
e.g 123 is just an example
perhaps tonumber() may be needed
check with regedit in the ce registry
also you can improve your code if you store the base address in the table itself. (or even in the Tag property of the menuitem)
Then you can use a for loop to see which one is checked and immediately have access to the base address as well
_________________
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: 1260
|
Posted: Fri Oct 25, 2019 5:21 pm Post subject: |
|
|
Razi wrote: | Tried, but it didn't work. Can you show a working example? |
Could be a little limited help. I don't have a chance to try. I'm on the phone. See the mgrInzPlayer archives. Here's an example:
Code: | settings=getSettings('test1')
function Save()
settings.Value['checkbox'] = s1==1 and '1' or '0'
settings.Value['checkbox1'] = s1==1 and '1' or '0'
settings.Value['checkbox2'] = s1==1 and '1' or '0'
settings.Value['checkbox3'] = s1==1 and '1' or '0'
end
function Load()
UDF1.CECheckbox1.Checked = settings.Value['checkbox']=='1' --or delete =='1'
UDF1.CECheckbox2.Checked = settings.Value['checkbox1']=='1'
UDF1.CECheckbox3.Checked = settings.Value['checkbox2']=='1'
UDF1.CECheckbox4.Checked = settings.Value['checkbox3"]=='1'
end
Load()
Form.OnClose = function
Save()
CloseCE()
end
|
_________________
|
|
Back to top |
|
|
Razi Expert Cheater Reputation: 1
Joined: 17 Jan 2018 Posts: 202
|
Posted: Sat Oct 26, 2019 4:21 am Post subject: |
|
|
Dark Byte wrote: | Did you confirm the value saved and loaded was what you set it to?
e.g 123 is just an example
perhaps tonumber() may be needed
| Did something wrong and value was always == nil
Aylin wrote: | Could be a little limited help. I don't have a chance to try. I'm on the phone. See the mgrInzPlayer archives. Here's an example:
|
Created a form with four checkboxes. Still can't get it to work. All checkboxes are always checked at startup.
Code: | settings=getSettings('test1')
function Save()
for x = 1, 4 do
if UDF1["CECheckbox"..x].Checked == true then
settings.Value['checkbox'..x] = x
end
end
end
function Load()
for x = 1, 4 do
UDF1["CECheckbox"..x].Checked = settings.Value['checkbox'..x]
end
end
Load()
UDF1.OnClose = function()
Save()
CloseCE()
end |
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Oct 26, 2019 10:02 am Post subject: |
|
|
If you have "checkbox" and "edit' controls inside a panel, e.g. CEPanel1, you can use script similar to one below.
Code: | function saveSettings(place,control)
local settings=getSettings(place)
for i=0,control.ControlCount-1 do
local className = control.Control[i].ClassName
if className=='TCECheckBox' then
settings.Value[control.Control[i].Name] = control.Control[i].State
end
if className=='TCEEdit' then
settings.Value[control.Control[i].Name] = control.Control[i].Text
end
end
settings.destroy()
end
function loadSettings(place,control)
local settings=getSettings(place)
for i=0,control.ControlCount-1 do
local className = control.Control[i].ClassName
if className=='TCECheckBox' then
local val = settings.Value[control.Control[i].Name]
if val~='' then control.Control[i].State = tonumber(val) end
end
if className=='TCEEdit' then
local val = settings.Value[control.Control[i].Name]
if val~='' then control.Control[i].Text = val end
end
end
settings.destroy()
end
loadSettings('mgrinzPlayer\\Test', UDF1.CEPanel1)
UDF1.OnClose = function()
saveSettings('mgrinzPlayer\\Test', UDF1.CEPanel1)
CloseCE()
end |
_________________
|
|
Back to top |
|
|
Razi Expert Cheater Reputation: 1
Joined: 17 Jan 2018 Posts: 202
|
Posted: Sun Oct 27, 2019 10:14 pm Post subject: |
|
|
Sorry for the late reply. Tried many times. It works for checkboxes with State property and does not work for checkboxes with Checked property. But I can use combobox with ItemIndex property in this case.
Code: | function saveSettings()
local settings=getSettings('Test')
for x = 1, 2 do
settings.Value[UDF1["CECheckbox"..x].Name] = UDF1["CECheckbox"..x].State
end
settings.Value[UDF1.CEEdit1.Name] = UDF1.CEEdit1.Text
settings.Value[UDF1.CEComboBox1.Name] = UDF1.CEComboBox1.ItemIndex
for x = 2, 4 do
if UDF1["MenuItem"..x].Checked == true then
settings.Value[UDF1["MenuItem"..x].Name] = UDF1["MenuItem"..x].Checked
end
end
settings.destroy()
end
function loadSettings()
local settings=getSettings('Test')
for x = 1, 2 do
local val = settings.Value[UDF1["CECheckbox"..x].Name]
if val~='' then UDF1["CECheckbox"..x].State = tonumber(val) end
end
local val = settings.Value[UDF1.CEEdit1.Name]
if val~='' then UDF1.CEEdit1.Text = val end
local val = settings.Value[UDF1.CEComboBox1.Name]
if val~='' then UDF1.CEComboBox1.ItemIndex = val end
for x = 2, 4 do
local val = settings.Value[UDF1["MenuItem"..x].Name]
if val~='' then UDF1["MenuItem"..x].Checked = tonumber(val) end
end
settings.destroy()
end
loadSettings()
UDF1.OnClose = function()
saveSettings()
CloseCE()
end |
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Mon Oct 28, 2019 3:54 am Post subject: |
|
|
Checked property type is boolean.
settings.Value[somethinghere] type is string.
When saving to registry, CE automatically converts other types (numbers and booleans) to string. link
Boolean type is converted to string like this: true => "1"; false => "0"
When loading from registry, you have to handle value types yourself. You can achieve that with simple expressions:
- for number: tonumber(val)
- for boolean: (val=='1')
Code: | local val = settings.Value[control.Control[i].Name]
-- checked property
if className=='TCECheckBox' then
if val~='' then control.Control[i].Checked = (val=='1') end
end |
Note: For checkboxes I prefer State property, because it can handle AllowGrayed
Tip
try to not use just game name here, e.g.:
Code: | getSettings('Blasphemous') |
Because it can interfere with settings from other users. It is unlikely that this will happen but still.
You can use this pattern for other CheatTables:
Code: | getSettings('Razi\\Blasphemous')
getSettings('Razi\\Prey')
getSettings('Razi\\Borderlands 3') |
_________________
|
|
Back to top |
|
|
Razi Expert Cheater Reputation: 1
Joined: 17 Jan 2018 Posts: 202
|
Posted: Mon Oct 28, 2019 9:38 am Post subject: |
|
|
mgr.inz.Player wrote: | Boolean type is converted to string like this: true => "1"; false => "0"
When loading from registry, you have to handle value types yourself. You can achieve that with simple expressions:
- for number: tonumber(val)
- for boolean: (val=='1') |
Used the following code and it did not work:
Code: | for x = 2, 4 do
local val = settings.Value[UDF1["MenuItem"..x].Name]
if val~='' then UDF1["MenuItem"..x].Checked = true end
end |
Thanks a lot, now everything works as it should. I would never have guessed that I need to use the following code in this way: for boolean: (val=='1')
|
|
Back to top |
|
|
|