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 


How to get / set dropdown lists

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Y.A.K.E
Advanced Cheater
Reputation: 0

Joined: 15 Jul 2019
Posts: 51

PostPosted: Wed Jun 29, 2022 8:44 am    Post subject: How to get / set dropdown lists Reply with quote

CETrainer.CEComboBox1

dropdown lists
Code:

1:Human
2:Barbarian
8:Half-elf
14:Elf
15:Dark Elf

.....





Code:

--read
function CETrainer_CEButton1Click(sender)

    local val = readInteger(getAddress("[entity_type]+4"))
    --CETrainer.CEComboBox1.ItemIndex = ?

end


--write
function CETrainer_CEButton2Click(sender)
    --local val = ?
    --writeInteger(getAddress("[entity_type]+4"),val)

end

Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1253

PostPosted: Wed Jun 29, 2022 11:24 am    Post subject: Reply with quote

Try this code in a separate tab.
( Lua Script: CheatTable >> File >> + New Tab )

Copy the code, paste it in the new tab and run.
Take what works for you from the code and change the names of the objects according to your own form.

Code:
if form then form.Destroy() form=nil end
form = createForm()
  form.Width = 300
  form.Height = 100
  form.BorderStyle = bsSingle
  form.Position = poScreenCenter
  form.PopupMode = 0
  form.Caption = name or 'Select Item'

  combobox1 = createComboBox(form)
  combobox1.Width = form.Width - 20
  combobox1.Left = 10
  combobox1.Top = 15

  edit1 = createEdit(form)
  edit1.Width = 80
  edit1.Left = 45
  edit1.Top = 60

  button1 = createButton(form)
  button1.Width = 100
  button1.Left = 150
  button1.Top = 60
  button1.Caption = 'Print'

  local setTbl = {"Human","Barbarian","Half-elf","Elf","Dark Elf"}

  combobox1.items.add("Select Item")
  combobox1.itemIndex=0
-- set
  for i,k in pairs(setTbl) do
    combobox1.items.add(k)
  end

-- Get items

edit1.OnChange=function()
  local b=tonumber(edit1.Text)
  if b~=nil then
    if b>#setTbl then
     showMessage("Max limit: " .. #setTbl)
     else
     combobox1.itemIndex=edit1.Text
    end
    else
     edit1.Text=""
  end
if edit1.Text=="" then combobox1.itemIndex=0 end
end


button1.OnClick=function()
print(combobox1.Text)
end

_________________
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