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 


Change address value with combobox items

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
matteo02p
How do I cheat?
Reputation: 0

Joined: 09 Dec 2022
Posts: 2

PostPosted: Wed Jan 04, 2023 12:37 pm    Post subject: Change address value with combobox items Reply with quote

I wanna change a 4 Byte address value with combobox's items this is the code.

I tried to use:

Code:
local address = getAddressSafe("WeaponIDs")

   if (item==1) then writeInteger(address, 1) return end
   if (item==2) then writeInteger(address, 2) return end
   if (item==3) then writeInteger(address, 4) return end
   if (item==4) then writeInteger(address, 5) return end
   if (item==5) then writeInteger(address, 6) return end


I used OnChange event on it...
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Wed Jan 04, 2023 4:27 pm    Post subject: Reply with quote

Code:
-- edit trainer name ..
local CBox1 = yourTrainerName.CECombobox1
-- edit Cbox list.
local tblMaterials={"İtem 1","İtem 2","İtem 3","İtem 4","İtem 5"}

CBox1.clear()
CBox1.Items.Add("Select Materials")
for i,k in pairs(tblMaterials) do
CBox1.Items.Add(k)
end

CBox1.ItemIndex="0"

CBox1.OnChange=function()
local item = CBox1.ItemIndex
 -- item=tonumber(item)
 local address = getAddressSafe("WeaponIDs")

   if (item==1) then writeInteger(address, 1)  end
   if (item==2) then writeInteger(address, 2)  end
   if (item==3) then writeInteger(address, 4)  end
   if (item==4) then writeInteger(address, 5)  end
   if (item==5) then writeInteger(address, 6)  end
  -- print("Index: " .. CBox1.ItemIndex)
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
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Wed Jan 04, 2023 9:13 pm    Post subject: Reply with quote

You can do something like this
Code:

if f then f.destroy(); f=nil end

weaponIDs = {
['Sword']    = 0x100,
['Axe']      = 0x101,
['Bow']      = 0x102,
['Staff']    = 0x103,
['Wand']     = 0x104,
['Shuriken'] = 0x105,
}

f = createForm(getMainForm())
f.Caption = 'Combobox Demo'
f.Width = 350
f.Height = 60
f.Top = 300
f.Left = 600

comboBox = createComboBox(f)
comboBox.Width = f.Width - 20
comboBox.Height = 30
comboBox.Top = f.Height - (comboBox.Height * 1.5)
comboBox.Left = (f.Width - comboBox.Width) / 2
comboBox.Sorted = true

font = createFont(f)
font.Name = 'Segoe UI'
font.Size = 10
font.Color = 0x333333
font.Quality = 'fqCleartypeNatural'

label = createLabel(f)
label.Font = font
label.Autosize = false
label.Width = 100
label.Height = 30
label.Top = comboBox.Top - (label.Height / 1.5)
label.Left = comboBox.Left
label.Caption = 'Select Materials:'

-- Populate ComboBox --
for k,v in pairs(weaponIDs) do
   comboBox.Items.Add(k)
end
-----------------------
-- Logic To Change Value Based On ID --
comboBox.OnChange = function()
                       --[[
                       -- To Set An Entry In The Table To The Value Selected
                       local mr = AddressList.getMemoryRecordByDescription('Weapon ID')
                       if mr ~= nil then
                         mr.value = weaponIDs[comboBox.text]
                       end
                       ]]

                       --[[
                       -- To Write Directly To The Address
                       local IDAddress = getAddressSafe(address_here)
                       if IDAddress ~= nil then
                          writeInteger(IDAddress, weaponIDs[comboBox.text])
                       end
                       ]]

                       -- Print To Console To Demonstrate
                       print(string.format('%X', weaponIDs[comboBox.text]))
                    end
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