|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
rayshoo92 Newbie cheater Reputation: 0
Joined: 30 Jan 2017 Posts: 13
|
Posted: Wed Feb 01, 2017 1:48 am Post subject: How to make checklist being auto uncheck? |
|
|
In Cheatengine Trainer
I have 4 togglebox(box1, box2, box3, box4)
and I want to make
If I check box 1 then check box2, Box1 should be unchecked
If I check box 2 then check box 4, Box2 should be unchecked
like this
Code: |
function CEToggleBox1Change(sender)
if (CETrainer.CEToggleBox1.State==cbChecked) then
(CETrainer.CEToggleBox2.State==unChecked)
(CETrainer.CEToggleBox3.State==unChecked)
(CETrainer.CEToggleBox4.State==unChecked)
writeInteger("address","value")
else
end
end
function CEToggleBox2Change(sender)
if (CETrainer.CEToggleBox2.State==cbChecked) then
(CETrainer.CEToggleBox1.State==unChecked)
(CETrainer.CEToggleBox3.State==unChecked)
(CETrainer.CEToggleBox4.State==unChecked)
writeInteger("address","value")
else
end
end
function CEToggleBox3Change(sender)
if (CETrainer.CEToggleBox3.State==cbChecked) then
(CETrainer.CEToggleBox1.State==unChecked)
(CETrainer.CEToggleBox2.State==unChecked)
(CETrainer.CEToggleBox4.State==unChecked)
writeInteger("address","value")
else
end
end
function CEToggleBox4Change(sender)
if (CETrainer.CEToggleBox4.State==cbChecked) then
(CETrainer.CEToggleBox1.State==unChecked)
(CETrainer.CEToggleBox2.State==unChecked)
(CETrainer.CEToggleBox3.State==unChecked)
writeInteger("address","value")
else
end
end
|
but it doesn`t work..
Please help me
|
|
Back to top |
|
|
usernotfound Expert Cheater Reputation: 0
Joined: 21 Feb 2016 Posts: 115
|
Posted: Wed Feb 01, 2017 2:29 am Post subject: |
|
|
Why not just use radio buttons instead?
|
|
Back to top |
|
|
rayshoo92 Newbie cheater Reputation: 0
Joined: 30 Jan 2017 Posts: 13
|
Posted: Wed Feb 01, 2017 2:40 am Post subject: |
|
|
Glare wrote: | Why not just use radio buttons instead? |
I prefer ordinary Buttons design
and for other functions it`s necessary
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Wed Feb 01, 2017 3:05 am Post subject: |
|
|
Quote: | I have 4 togglebox(box1, box2, box3, box4)
and I want to make
If I check box 1 then check box2, Box1 should be unchecked
If I check box 2 then check box 4, Box2 should be unchecked |
As you said it's "checkbox", but on your script seem you use "ToggleBox", btw whatever...
Maybe like this..
Code: | CETrainer.show()
Tgbox1 = CETrainer.CEToggleBox1
Tgbox2 = CETrainer.CEToggleBox2
Tgbox3 = CETrainer.CEToggleBox3
Tgbox4 = CETrainer.CEToggleBox4
on = cbChecked
off = cbUnchecked
function TgboxChange1(sender)
if Tgbox1.State == on then
Tgbox1.Caption = "On"
Tgbox2.State = off; Tgbox2.Caption = "Off";
Tgbox3.State = off; Tgbox3.Caption = "Off";
Tgbox4.State = off; Tgbox4.Caption = "Off";
CETrainer.CELabel1.Caption = "ToggleBox 1 ON";end
---- writeInteger("address","value") --- or do something
end
function TgboxChange2(sender)
if Tgbox2.State == on then
Tgbox2.Caption = "On"
Tgbox1.State = off; Tgbox1.Caption = "Off";
Tgbox3.State = off; Tgbox3.Caption = "Off";
Tgbox4.State = off; Tgbox4.Caption = "Off";
CETrainer.CELabel1.Caption = "ToggleBox 2 ON";end
---- writeInteger("address","value") --- or do something
end
function TgboxChange3(sender)
if Tgbox3.State == on then
Tgbox3.Caption = "On"
Tgbox1.State = off; Tgbox1.Caption = "Off";
Tgbox2.State = off; Tgbox2.Caption = "Off";
Tgbox4.State = off; Tgbox4.Caption = "Off";
CETrainer.CELabel1.Caption = "ToggleBox 3 ON";end
---- writeInteger("address","value") --- or do something
end
function TgboxChange4(sender)
if Tgbox4.State == on then
Tgbox4.Caption = "On"
Tgbox1.State = off; Tgbox1.Caption = "Off";
Tgbox2.State = off; Tgbox2.Caption = "Off";
Tgbox3.State = off; Tgbox3.Caption = "Off";
CETrainer.CELabel1.Caption = "ToggleBox 4 ON";end
---- writeInteger("address","value") --- or do something
end
if Tgbox1.State == off and Tgbox2.State == off and Tgbox3.State == off and Tgbox4.State == off then
Tgbox1.State = off; Tgbox1.Caption = "Off";
Tgbox2.State = off; Tgbox2.Caption = "Off";
Tgbox3.State = off; Tgbox4.Caption = "Off";
Tgbox4.State = off; Tgbox4.Caption = "Off";
CETrainer.CELabel1.Caption = "No ToggleBoxs ON"
end
Tgbox1.onChange = TgboxChange1
Tgbox2.onChange = TgboxChange2
Tgbox3.onChange = TgboxChange3
Tgbox4.onChange = TgboxChange4 |
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Wed Feb 01, 2017 3:20 am Post subject: |
|
|
ToggleBox behaves like a checkbox, so you can just do
Code: |
if (CETrainer.CEToggleBox1.Checked) then
(CETrainer.CEToggleBox2.Checked=false)
(CETrainer.CEToggleBox3.Checked=false)
(CETrainer.CEToggleBox4.Checked=false)
writeInteger("address","value")
end
|
_________________
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: Wed Feb 01, 2017 3:23 am Post subject: |
|
|
True, DB
|
|
Back to top |
|
|
rayshoo92 Newbie cheater Reputation: 0
Joined: 30 Jan 2017 Posts: 13
|
Posted: Wed Feb 01, 2017 3:25 am Post subject: |
|
|
I love you guys
Happy new year and hope always fine
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Wed Feb 01, 2017 4:08 am Post subject: |
|
|
May try this function? May be handy if changing number of buttons.
Code: |
function radioBehavior(OnChange)
return function(me)
local p = me.Parent
if p and p.ControlCount then
local myClass,Cnt = me.ClassName,0
for i=0,p.ControlCount-1 do
local c = p.Control[i]
if c~=me and myClass == c.ClassName and c.Checked==true then
if me.Checked then
c.Checked = false
else
Cnt = Cnt + 1
end
end
end
if false == me.Checked and Cnt == 0 then me.Checked = true end
end
if type(OnChange)=='function' then synchronize(OnChange,me)end
end
end
|
This will make those sibling controls having same class and .Checked property under a Parent Control behavior like a radio button group,
optionally allow other OnChange handler attach to individual control.
ADDED:
oops, not exactly radio group behavior...
clicking an Checked button will uncheck it,
should remain Checked once checked,
so that at least one button checked in group.
<Fixed>
eg.
Code: |
local function ceUpd(o,t,b)
if type(o)=='function' then o,t,b = t,b,o end
for k,v in pairs(t) do
if type(k)=='string' then
o[k]=type(v)=='table' and ceUpd(o[k] or {},v,b)or v
end
end
if b then for i=1,#t do b(o,t[i])end end
return o
end
local function bGui(parent,prop,...)
if type(parent)=='string'and _G['create'..parent] then
parent = _G['create'..parent](...)
return ceUpd(parent,prop,bGui)
end
local make = type(prop)=='table' and type(prop._)=='string' and _G['create'..prop._]
if make then
prop._=nil
local c = make(parent)
return ceUpd(c,prop,bGui)
end
end
-- ^ helper functions to build gui
-- test
local ff
local function setIndex(n) -- OnChange handler to make selected Index
return function(me)--me is a checkbox or toggle box
ff.RG.Index.Caption = n
end
end
ff = bGui("Form",{
Width = 300,
Height = 100,
Constraints = {MinWidth=200,MinHeight=100},
BorderStyle = bsSizeable,
OnClose = function(fm)return caFree end,
{ _='RadioGroup',
Name = 'RG', Align = alTop, AutoSize = true,
{ _='ToggleBox',
Name = 't1', Caption = 'Button 1', Align = alBottom,
OnChange = radioBehavior(function(me)me.Parent.Color=bXor(me.Parent.Color,0x10) end)
},
{ _='ToggleBox',
Name = 't2', Caption = 'Button 2', Align = alBottom,
OnChange = radioBehavior()
},
{ _='ToggleBox',
Name = 't3', Caption = 'Button 3', Align = alBottom,
OnChange = radioBehavior()
},
{ _='ToggleBox',
Name = 't4', Caption = 'Button 4', Align = alBottom,
OnChange = radioBehavior()
},
{ _='CheckBox',
Name = 'c1', Caption = 'Button 1', Align = alBottom,
OnChange = radioBehavior(setIndex(1))
-- setup to send index to ff.RG.Index edit box
},
{ _='CheckBox',
Name = 'c2', Caption = 'Button 2', Align = alBottom,
OnChange = radioBehavior(setIndex(2))
},
{ _='CheckBox',
Name = 'c3', Caption = 'Button 3', Align = alBottom,
OnChange = radioBehavior(setIndex(3))
},
{ _='CheckBox',
Name = 'c4', Caption = 'Button 4', Align = alBottom,
OnChange = radioBehavior(setIndex(4))
},
{ _='Label', Align = alBottom,
Caption = 'CheckBox Index :'
},
{ _='Label', Name = 'Index', Align = alBottom,
Caption = '-1', Color = 0xffffff
},
},
},false)
ff.AutoSize = true -- should resize after create all control
ff.Show()
|
bye~
_________________
- Retarded.
Last edited by panraven on Wed Feb 01, 2017 12:16 pm; edited 1 time in total |
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Wed Feb 01, 2017 6:50 am Post subject: |
|
|
Panraven bro,
Tested your script:
Nothing happen when clicking button3 and button4
Other, would you give syntax pattern for function bGui(parent,prop,...) ?
Thank you
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Wed Feb 01, 2017 7:29 am Post subject: |
|
|
Corroder wrote: | Panraven bro,
Tested your script:
Nothing happen when clicking button3 and button4
Other, would you give syntax pattern for function bGui(parent,prop,...) ?
Thank you |
Work as expect on my CE 6.6 after copy and paste, should have no typo.
I've edited it some time, may try again.
For the syntax, may think it like HTML that attribute is string type key, while html child tab as numeric key of an Lua array.
In Lua table literal, string key match an Lua identifier (non keyword, start with underscore letter, followed by underscore letter digit) can be unquoted, eg.
Code: |
{
_ = "Button" -- "_" is special string key to tell what gui to create, must match a ce global function "create<Button>" etc.
Width = 300, -- string key for gui attribute for current ui
Height = 100,
{...child ui specification..}, -- implicit numeric array key 1
{...etc...}, -- implicit numeric array key 2
}
|
In case the attribute is an ce object, like Constraints or Font, may specific its child attribute like:
Code: |
{
Font = {Name = "Courier New", Color = 0xff},
Constraints = {MinWidth=100, MinHeight=100}
}
|
The CE gui has recursive nature similar to HTML tag and so is Lua Table structure. May try make some gui and get used to it if interested.
bye~
_________________
- Retarded. |
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Wed Feb 01, 2017 6:40 pm Post subject: |
|
|
Thanks panraven bro, for details explain.
So, it's like HTML body tag pattern. something like this..
Code: | <html>
<head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body>
</html>
|
Will try the function and implement it to my script.
Regards
|
|
Back to top |
|
|
rayshoo92 Newbie cheater Reputation: 0
Joined: 30 Jan 2017 Posts: 13
|
Posted: Thu Feb 02, 2017 11:40 am Post subject: |
|
|
Hey guys
Actually I try some of them but it didn`t work
but I finally made it
Here`s code
Code :
Code: |
function CEToggleBox1On()
setProperty(CETrainer.CEToggleBox1,"State", "1")
setProperty(CETrainer.CEToggleBox2,"State", "0")
setProperty(CETrainer.CEToggleBox3,"State", "0")
setProperty(CETrainer.CEToggleBox4,"State", "0")
end
function CEToggleBox2On()
setProperty(CETrainer.CEToggleBox1,"State", "0")
setProperty(CETrainer.CEToggleBox2,"State", "1")
setProperty(CETrainer.CEToggleBox3,"State", "0")
setProperty(CETrainer.CEToggleBox4,"State", "0")
end
function CEToggleBox3On()
setProperty(CETrainer.CEToggleBox1,"State", "0")
setProperty(CETrainer.CEToggleBox2,"State", "0")
setProperty(CETrainer.CEToggleBox3,"State", "1")
setProperty(CETrainer.CEToggleBox4,"State", "0")
end
function CEToggleBox4On()
setProperty(CETrainer.CEToggleBox1,"State", "0")
setProperty(CETrainer.CEToggleBox2,"State", "0")
setProperty(CETrainer.CEToggleBox3,"State", "0")
setProperty(CETrainer.CEToggleBox4,"State", "1")
end
function CEToggleBox1Change(sender)
if (CETrainer.CEToggleBox1.State==cbChecked) then
CEToggleBox1On()
writeInteger("address","Value")
else end
end
|
It seems there is another better way..
but anyway, it works well
Hope if someone need it . Try this (on ToggleBox)
Edit :
I forgot `off` function when I press twice to one button
and I edited like this
Code: |
function CEToggleBox1On()
setProperty(CETrainer.CEToggleBox1,"State", "1")
end
function CEToggleBox1Off()
setProperty(CETrainer.CEToggleBox1,"State", "0")
end
function CEToggleBox2On()
setProperty(CETrainer.CEToggleBox2,"State", "1")
end
function CEToggleBox2Off()
setProperty(CETrainer.CEToggleBox2,"State", "0")
end
function CEToggleBox3On()
setProperty(CETrainer.CEToggleBox3,"State", "1")
end
function CEToggleBox3Off()
setProperty(CETrainer.CEToggleBox3,"State", "0")
end
function CEToggleBox4On()
setProperty(CETrainer.CEToggleBox4,"State", "1")
end
function CEToggleBox4Off()
setProperty(CETrainer.CEToggleBox4,"State", "0")
end
function CEToggleBox5On()
setProperty(CETrainer.CEToggleBox5,"State", "1")
end
function CEToggleBox5Off()
setProperty(CETrainer.CEToggleBox5,"State", "0")
end
function CEToggleBox6On()
setProperty(CETrainer.CEToggleBox6,"State", "1")
end
function CEToggleBox6Off()
setProperty(CETrainer.CEToggleBox6,"State", "0")
end
function CEToggleBox1Change(sender)
if (CETrainer.CEToggleBox1.State==cbChecked) then
CEToggleBox1On()
CEToggleBox2Off()
CEToggleBox3Off()
CEToggleBox4Off()
writeInteger("address","value1")
else
CEToggleBox1Off()
writeInteger("address","defaultvalue") end
end
function CEToggleBox2Change(sender)
if (CETrainer.CEToggleBox2.State==cbChecked) then
CEToggleBox1Off()
CEToggleBox2On()
CEToggleBox3Off()
CEToggleBox4Off()
writeInteger(address,"value2")
else
CEToggleBox2Off()
writeInteger(address,"defaultvalue") end
end
function CEToggleBox3Change(sender)
if (CETrainer.CEToggleBox3.State==cbChecked) then
CEToggleBox1Off()
CEToggleBox2Off()
CEToggleBox3On()
CEToggleBox4Off()
writeInteger(address,"value3")
else
CEToggleBox3Off()
writeInteger(address1,"defaultvalue") end
end
function CEToggleBox4Change(sender)
if (CETrainer.CEToggleBox4.State==cbChecked) then
CEToggleBox1Off()
CEToggleBox2Off()
CEToggleBox3Off()
CEToggleBox4On()
writeInteger(address1,"value4")
else
CEToggleBox4Off()
writeInteger(address1,"defaultvalue") end
end
|
|
|
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
|
|