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 


Implementation ComboBox, CEEdit and Array (Correlation)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri Oct 30, 2015 9:08 pm    Post subject: Implementation ComboBox, CEEdit and Array (Correlation) Reply with quote

Hi guys,

I try to implements correlation ComboBox, CEEdit and an array table.
(Continue learning never stop.... )

Step by step I wan to do :
1. Pick an item from ComboBox items list
2. When an item chose, CEEdit Caption will show "Item Name" relating to correct index number of both ComboBox items list and array table

I can do like this :
Code:

function cbboxOnChange()
index=getProperty(cbbox, "ItemIndex")
if index == -1 then return end;
if index == 0 then control_setCaption(edit1,"Pick an item") end;
 if index == 1 then
  control_setCaption(edit1,"Code 1")
 elseif index == 2 then
  control_setCaption(edit1,"Code 2")
 elseif index == 3 then
  control_setCaption(edit1,"Code 3")
 elseif index == 4 then
  control_setCaption(edit1,"Code 4")
 elseif index == 5 then
  control_setCaption(edit1,"Code 5")
 end
end


but if i have too many options for items list and array table, then i have problem (too lazy typing all of filter keys)

Does someone should fix it with "for..do" command ?

complete code i tried :
Code:

---------------------------------------  Form
f = createForm(false)
control_setSize(f, 170, 180)
control_setCaption(f,"Test")
f.show()

-------------------------------------- Label
label = createLabel(f)
control_setPosition(label, 10, 150)
control_setCaption(label, "Waiting..")

------------------------------------- Edit
edit1 = createEdit(f)
control_setSize(edit1, 150, 100)
control_setPosition(edit1, 10,50)

------------------------------------- ComboBox
cbbox = createComboBox(f)
control_setSize(cbbox, 150, 100)
control_setPosition(cbbox, 10,10)
items = combobox_getItems(cbbox)
strings_add(items,"Pick an item")
strings_add(items,"0x5243047")
strings_add(items,"0x16775408")
strings_add(items,"0x14150650")
strings_add(items,"0x14413823")
strings_add(items,"0x13426670")

tbl_array = {{IndexNo="0x5243047",IdName="Code 1"},{IndexNo="0x16775408",IdName="Code 2"},
             {IndexNo="0x14150650",IdName="Code 3"},{IndexNo="0x14413823",IdName="Code 4"},
             {IndexNo="0x13426670",IdName="Code 5"}}

function cbboxOnChange()
index=getProperty(cbbox, "ItemIndex")
if index == -1 then return end;
if index == 0 then control_setCaption(edit1,"Pick an item") end;
 if index == 1 then
  control_setCaption(edit1,"Code 1")
 elseif index == 2 then
  control_setCaption(edit1,"Code 2")
 elseif index == 3 then
  control_setCaption(edit1,"Code 3")
 elseif index == 4 then
  control_setCaption(edit1,"Code 4")
 elseif index == 5 then
  control_setCaption(edit1,"Code 5")
 end
end

--- for i = index, #tbl_array do
--- itemSelect = combobox_getItems(cbbox, i)
--- if tbl_array[i].IndexNo == itemSelect then
--  control_setCaption(edit1, tbl_array[i].IdName)
--- end
--- end
----end

setMethodProperty(cbbox, "OnChange", cbboxOnChange)


------------------------------------ Button
button = createButton(f)
control_setSize(button, 150, 40)
control_setPosition(button, 10, 90)
control_setCaption(button, "Get It")

function buttonClick()
catch = control_getCaption(edit1)
control_setCaption(label, catch)
end
setMethodProperty(button, "OnClick", buttonClick)


Oh, one more question : What syntax to make property of ComboBox as DropDownList ?
Regards
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Fri Oct 30, 2015 9:51 pm    Post subject: Reply with quote

Code:
f = createForm(false)
control_setSize(f, 170, 180)
control_setCaption(f,"Test")
f.show()

-------------------------------------- Label
label = createLabel(f)
control_setPosition(label, 10, 150)
control_setCaption(label, "Waiting..")

------------------------------------- Edit
edit1 = createEdit(f)
control_setSize(edit1, 150, 100)
control_setPosition(edit1, 10,50)

cbbox = createComboBox(f)
cbbox.Style = "csDropDownList" -- do not allow free text
control_setSize(cbbox, 150, 100)
control_setPosition(cbbox, 10,10)
items = combobox_getItems(cbbox)
strings_add(items, "Pick an item")
cbbox.ItemIndex = 0 -- select this first option

tbl_array = {
  {IndexNo="0x5243047",IdName="Code 1"},
  {IndexNo="0x16775408",IdName="Code 2"},
  {IndexNo="0x14150650",IdName="Code 3"},
  {IndexNo="0x14413823",IdName="Code 4"},
  {IndexNo="0x13426670",IdName="Code 5"}
}

for i,v in ipairs(tbl_array) do
  strings_add(items, v.IndexNo)
end

function cbboxOnChange()
  index = getProperty(cbbox, "ItemIndex")
  index = tbl_array[index]
  if index == nil then
    control_setCaption(edit1,"Pick an item")
  else
    control_setCaption(edit1, index.IdName)
  end
end

setMethodProperty(cbbox, "OnChange", cbboxOnChange)
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Oct 31, 2015 3:04 am    Post subject: Reply with quote

Thank so much Zanzer,

Everything in my CT file is work fine now.
Here is the result :
http://forum.cheatengine.org/viewtopic.php?p=5626298#5626298

Regard
Back to top
View user's profile Send private message
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