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 


Conditional dropdown list?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
buyx86
Advanced Cheater
Reputation: 0

Joined: 10 May 2011
Posts: 82
Location: Philippines

PostPosted: Wed May 01, 2024 10:54 pm    Post subject: Conditional dropdown list? Reply with quote

This is my post from https://forum.cheatengine.org/viewtopic.php?p=5789419#5789419. I just transferred it here because this is the relevant section for it.

From AylinCE:
Quote:
Approximate answer to your question:

Code:
if frm1 then frm1.Destroy() frm1=nil end
frm1=createForm()

CEtrainer = {}
CEtrainer.CTComboBox1=createComboBox(frm1)
CEtrainer.CTComboBox1.Left=30
CEtrainer.CTComboBox1.Top=50
CEtrainer.CTComboBox1.ReadOnly=true
CEtrainer.CTComboBox1.Style='csDropDownList'

CEtrainer.Btn1=createButton(frm1)
CEtrainer.Btn1.Left=140 CEtrainer.Btn1.Top=50
CEtrainer.Btn1.Caption="condition 1"

CEtrainer.Btn2=createButton(frm1)
CEtrainer.Btn2.Left=140 CEtrainer.Btn2.Top=80
CEtrainer.Btn2.Caption="condition 2"

CEtrainer.Btn3=createButton(frm1)
CEtrainer.Btn3.Left=140 CEtrainer.Btn3.Top=110
CEtrainer.Btn3.Caption="condition 3"

local condition = {"condition 0","description 1","description 2","description 3","description 4","description 5","description 6","description 7","description 8"}
local condition1 = {"condition 1","description 1","description 4","description 5"}
local condition2 = {"condition 2","description 2","description 3","description 6"}
local condition3 = {"condition 3","description 3","description 7","description 8"}

for i,k in pairs(condition) do
CEtrainer.CTComboBox1.Items.Add(k)
end
CEtrainer.CTComboBox1.ItemIndex=0

CEtrainer.Btn1.OnClick=function()
CEtrainer.CTComboBox1.Clear()
for i,k in pairs(condition1) do
CEtrainer.CTComboBox1.Items.Add(k)
end
CEtrainer.CTComboBox1.ItemIndex=0
end

CEtrainer.Btn2.OnClick=function()
CEtrainer.CTComboBox1.Clear()
for i,k in pairs(condition2) do
CEtrainer.CTComboBox1.Items.Add(k)
end
CEtrainer.CTComboBox1.ItemIndex=0
end

CEtrainer.Btn3.OnClick=function()
CEtrainer.CTComboBox1.Clear()
for i,k in pairs(condition3) do
CEtrainer.CTComboBox1.Items.Add(k)
end
CEtrainer.CTComboBox1.ItemIndex=0
end

CEtrainer.CTComboBox1.OnChange=function()
if CEtrainer.CTComboBox1.ItemIndex==0 then
CEtrainer.CTComboBox1.Clear()
for i,k in pairs(condition) do
CEtrainer.CTComboBox1.Items.Add(k)
end
CEtrainer.CTComboBox1.ItemIndex=0
end
end


To clarify what I want to achieve, I want to edit a character's skills when it is selected. I already have the code to get the base address of the selected character, and the offsets for character's class and skills. I also have the values for the class and skills together with their description. Example would be class=1 is for warrior and skill=11 is warrior attack. What I'm trying to do is to lockdown and limit the dropdown list options for a character's skills based on what class they are to maintain the game mechanics. If the character's class is a Warrior(value of 1) then the dropdown list options would be
    11:Warrior Attack
    192: Warrior Attack 2
    215:Guard Break
Back to top
View user's profile Send private message Yahoo Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 33

Joined: 16 Feb 2017
Posts: 1329

PostPosted: Thu May 02, 2024 3:27 am    Post subject: Reply with quote

The code I gave should meet your request.

Factors you need to regulate:
Fill in the tables I gave for "condition".
For example, put the entire list in the first table. (1~215..300 etc)
In the second table (condition1) add what will be in the list if "Warrior" is selected.
In the third table (condition2) add what will be in the list to load if "Wizard" is selected.
If necessary, create the 4th table (condition3) with the same logic or 5.. 6.. 7 tables..

Or create each character and its related conditions sequentially in a single table
For example; 1-25 belongs to "Warrior", 26-40 belongs to "Summoner", etc.

Or, it can only be scanned with the name similarity filter and the results can be listed.
Entries containing the word "Warrior" in the entire list are filtered and put into the new list, etc.

Or make a different coding list:

Code:
if frm1 then frm1.Destroy() frm1=nil end
frm1=createForm()

CEtrainer = {}
CEtrainer.CTComboBox1=createComboBox(frm1)
CEtrainer.CTComboBox1.Left=30
CEtrainer.CTComboBox1.Top=50
CEtrainer.CTComboBox1.ReadOnly=true
CEtrainer.CTComboBox1.Style='csDropDownList'

CEtrainer.Btn1=createButton(frm1)
CEtrainer.Btn1.Left=140 CEtrainer.Btn1.Top=50
CEtrainer.Btn1.Caption="warrior"

CEtrainer.Btn2=createButton(frm1)
CEtrainer.Btn2.Left=140 CEtrainer.Btn2.Top=80
CEtrainer.Btn2.Caption="Summoner"

CEtrainer.Btn3=createButton(frm1)
CEtrainer.Btn3.Left=140 CEtrainer.Btn3.Top=110
CEtrainer.Btn3.Caption="elf"

local condition = { -- edit: description = Warrior Attack etc..
 warrior = {"warrior","description 1","description 4","description 5"},
 Summoner = {"Summoner","description 2","description 3","description 6"},
 elf = {"elf""description 7","description 8","description 9"}}

for i,k in pairs(condition) do
     for j,l in pairs(condition[i]) do
       CEtrainer.CTComboBox1.Items.Add(l)
     end
end
CEtrainer.CTComboBox1.ItemIndex=0

CEtrainer.Btn1.OnClick=function()
CEtrainer.CTComboBox1.Clear()
 for i,k in pairs(condition.warrior) do
  CEtrainer.CTComboBox1.Items.Add(k)
 end
CEtrainer.CTComboBox1.ItemIndex=0
end

CEtrainer.Btn2.OnClick=function()
CEtrainer.CTComboBox1.Clear()
 for i,k in pairs(condition.Summoner) do
  CEtrainer.CTComboBox1.Items.Add(k)
 end
CEtrainer.CTComboBox1.ItemIndex=0
end

CEtrainer.Btn3.OnClick=function()
CEtrainer.CTComboBox1.Clear()
 for i,k in pairs(condition.elf) do
  CEtrainer.CTComboBox1.Items.Add(k)
 end
CEtrainer.CTComboBox1.ItemIndex=0
end

CEtrainer.CTComboBox1.OnChange=function()
  if CEtrainer.CTComboBox1.ItemIndex==0 then
    CEtrainer.CTComboBox1.Clear()
    for i,k in pairs(condition) do
     for j,l in pairs(condition[i]) do
       CEtrainer.CTComboBox1.Items.Add(l)
     end
    end
    CEtrainer.CTComboBox1.ItemIndex=0
  end
end


The code is just a simulation that transfers the input it receives to the list.

So, if you get a value of 1 from an address in the address list (button 1 function), you will display the list given for "warrior" in the main table.

You should edit this table with your own list:
Code:
local condition = { -- edit: description = Warrior Attack etc..
 warrior = {"warrior","description 1","description 4","description 5"},
 Summoner = {"Summoner","description 2","description 3","description 6"},
 elf = {"elf""description 7","description 8","description 9"}}

_________________
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
buyx86
Advanced Cheater
Reputation: 0

Joined: 10 May 2011
Posts: 82
Location: Philippines

PostPosted: Thu May 02, 2024 4:12 am    Post subject: Reply with quote

I made a mistake in not explaining properly what description is, the description there is not the string value description found on the character data. It's just what I want it to appear in the dropdown list. For example, if the value for the skill is 11, I want it that it would reflect on the dropdown list as Warrior Attack. It's the in-game name of the skill. I just followed the dropdown list format of "Value:Description". And some values have no skills, so the values of the skills are not in sequence. There are gaps on some numbers.
Back to top
View user's profile Send private message Yahoo Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 33

Joined: 16 Feb 2017
Posts: 1329

PostPosted: Thu May 02, 2024 4:22 am    Post subject: Reply with quote

1) Make a complete list of all skills.
2) Make a list of whichever skill (or value) is being selected.
3) Make lists of all your skills or values.

And send it here.

Note: Lists do not need to be very long. I want to provide you with an example to understand the general logic.

I will probably make an edit to the code I gave above.
Because you don't understand, I think I need to show this with your lists.

1) How many types of skills are there? (Warrior etc.)
2) Lists of things (belonging to the skill) that should be in the list if the skill or value is selected.

_________________
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
buyx86
Advanced Cheater
Reputation: 0

Joined: 10 May 2011
Posts: 82
Location: Philippines

PostPosted: Thu May 02, 2024 4:42 am    Post subject: Reply with quote

Sorry about this and thanks for taking your time helping. This is a sample.
For classes:
    1:Samurai
    3:Ashigaru
    13:Archer

For Samurai
    11:Warrior Attack
    182:Warrior Attack 2
    215:Guard Break

For Ashigaru:
    131:Ashigaru Attack
    184:Ashigaru Attack 2

For Archer:
    31:Bow Attack
    30:Bow Attack Plus
    171:Yamamoto Sweeping Fire
Back to top
View user's profile Send private message Yahoo Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 33

Joined: 16 Feb 2017
Posts: 1329

PostPosted: Thu May 02, 2024 5:28 am    Post subject: Reply with quote

I assume the numbers before the ":" you gave at the beginning of the description are the values.
Type a valid value in the box and click the button next to it.
If there is a value in your list, that list will be loaded into the "Dropdown list".

Select a name in the drop-down list and see the results it prints.

Use this code, test what it can do and state what you need.

Code:
if frm1 then frm1.Destroy() frm1=nil end
frm1=createForm()

CEtrainer = {}
CEtrainer.CTComboBox1=createComboBox(frm1)
CEtrainer.CTComboBox1.Left=30
CEtrainer.CTComboBox1.Top=50
CEtrainer.CTComboBox1.ReadOnly=true
CEtrainer.CTComboBox1.Style='csDropDownList'

CEtrainer.Btn1=createButton(frm1)
CEtrainer.Btn1.Left=140 CEtrainer.Btn1.Top=50
CEtrainer.Btn1.Caption="Samurai"

CEtrainer.Btn2=createButton(frm1)
CEtrainer.Btn2.Left=140 CEtrainer.Btn2.Top=80
CEtrainer.Btn2.Caption="Ashigaru"

CEtrainer.Btn3=createButton(frm1)
CEtrainer.Btn3.Left=140 CEtrainer.Btn3.Top=110
CEtrainer.Btn3.Caption="Archer"

CEtrainer.Btn4=createButton(frm1)
CEtrainer.Btn4.Left=140 CEtrainer.Btn4.Top=160
CEtrainer.Btn4.Caption="Value Update"

CEtrainer.Edt1=createEdit(frm1)
CEtrainer.Edt1.Left=50 CEtrainer.Edt1.Top=161
CEtrainer.Edt1.Caption="condition 3"

local condition = {
 Samurai = {"1:Samurai","11:Warrior Attack","182:Warrior Attack 2","215:Guard Break"},
 Ashigaru = {"3:Ashigaru","131:Ashigaru Attack","184:Ashigaru Attack 2"},
 Archer = {"13:Archer","31:Bow Attack","30:Bow Attack Plus","171:Yamamoto Sweeping Fire"}}

for i,k in pairs(condition) do
     for j,l in pairs(condition[i]) do
       l1 = l:match(":(.*)")
       CEtrainer.CTComboBox1.Items.Add(l1)
     end
end
CEtrainer.CTComboBox1.ItemIndex=0

function Samurai()
CEtrainer.CTComboBox1.Clear()
 for i,k in pairs(condition.Samurai) do
   k1 = k:match(":(.*)")
  CEtrainer.CTComboBox1.Items.Add(k1)
 end
CEtrainer.CTComboBox1.ItemIndex=0
end

function Ashigaru()
CEtrainer.CTComboBox1.Clear()
 for i,k in pairs(condition.Ashigaru) do
   k1 = k:match(":(.*)")
  CEtrainer.CTComboBox1.Items.Add(k1)
 end
CEtrainer.CTComboBox1.ItemIndex=0
end

function Archer()
CEtrainer.CTComboBox1.Clear()
 for i,k in pairs(condition.Archer) do
   k1 = k:match(":(.*)")
  CEtrainer.CTComboBox1.Items.Add(k1)
 end
CEtrainer.CTComboBox1.ItemIndex=0
end

CEtrainer.CTComboBox1.OnChange=function()
  if CEtrainer.CTComboBox1.ItemIndex==0 then
    CEtrainer.CTComboBox1.Clear()
    for i,k in pairs(condition) do
     for j,l in pairs(condition[i]) do
       l1 = l:match(":(.*)")
       CEtrainer.CTComboBox1.Items.Add(l1)
     end
    end
    CEtrainer.CTComboBox1.ItemIndex=0
  end
  for i,k in pairs(condition) do
     for j,l in pairs(condition[i]) do
       l1,l2 = l:match("(.*):(.*)")
        l3 = CEtrainer.CTComboBox1.Items[CEtrainer.CTComboBox1.ItemIndex]
        if l2==l3 then
         print("Value: "..l1.."\nName: "..l2)
        end
     end
  end
end

function searchValue()
local val = CEtrainer.Edt1.Text
local tbl
local res = 0
 if CEtrainer.Edt1.Text~="" then
  for i,k in pairs(condition) do
     for j,l in pairs(condition[i]) do
       l1 = l:match("(.*):")
        if l1==val then
         tbl=condition[i]
         res=1
        end
     end
  end
 else
   showMessage("Please write a value in the box!")
 end
    if res==1 then
      CEtrainer.CTComboBox1.Clear()
      for i,k in pairs(tbl) do
        k1 = k:match(":(.*)")
        CEtrainer.CTComboBox1.Items.Add(k1)
      end
        CEtrainer.CTComboBox1.ItemIndex=0
    else
      showMessage("The specified value was not found!")
    end
end

CEtrainer.Btn1.OnClick=Samurai
CEtrainer.Btn2.OnClick=Ashigaru
CEtrainer.Btn3.OnClick=Archer
CEtrainer.Btn4.OnClick=searchValue

_________________
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
buyx86
Advanced Cheater
Reputation: 0

Joined: 10 May 2011
Posts: 82
Location: Philippines

PostPosted: Thu May 02, 2024 6:34 am    Post subject: Reply with quote

It did filter it out properly. But I wanted it to be selectable on the directly on the CE table. This is a copy of the code that evaluates the class.
Code:
checkEditCmdr:
  cmp [eax+F0],0
  jne code4
  push edx
  mov edx,[pSelectedCmdr]
  cmp [eax+8],edx
  pop edx
  jne code4
  mov [pEditCmdr],eax  //selected commander base pointer
  cmp [eax+50],1    //evaluate class
  jne @f
  //need code to use dropdown list for samurai
  jmp code4
  @@:
  cmp [eax+50],3    //evaluate class
  jne @f
  //need code to use dropdown list for ashigaru
  jmp code4
  @@:
  cmp [eax+50],13  //evaluate class
  //need code to use dropdown list for archer
  jmp code4

I need a lua code that can create a local variable or memrec for skills depending on their class. Like the attached photo. I found a code from a table I downloaded for a different game. It's something like this.
Code:
local skills="100:Melee Attack 1\n101:Thrust Attack 1\n102:Melee Attack 2\n103:Thrust Attack....

Is it possible?

EDIT: After much searching in the internet, I understood that what I want is impossible. Too bad.



sample skills.jpg
 Description:
 Filesize:  80.85 KB
 Viewed:  561 Time(s)

sample skills.jpg




Last edited by buyx86 on Thu May 02, 2024 9:09 am; edited 1 time in total
Back to top
View user's profile Send private message Yahoo Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 33

Joined: 16 Feb 2017
Posts: 1329

PostPosted: Thu May 02, 2024 9:08 am    Post subject: This post has 1 review(s) Reply with quote

I based it on the entries in the picture.
That is, when you click on the button on the side, the entry list in the button function is loaded and focuses on the name in the address description.

First click the button, then select a value from the list.

When you select a value from the list, the address will change with numbers.
So if "182:Warrior Attack 2" is selected, it will push 182 to the address.
If you want to change this and print "Warrior Attack 2" to the address (the value appears as a string in the picture), change this to "l2" in the relevant code snippet.

Code:
        if l2==l3 then
         CheatEdt1.Value=l1 -- l2 <<<<--------
         CEtrainer.Edt2.Text = CheatEdt1.Value
         print("Value: "..l1.."\nName: "..l2)
        end


Code:
if frm1 then frm1.Destroy() frm1=nil end
frm1=createForm()

CEtrainer = {}
CEtrainer.CTComboBox1=createComboBox(frm1)
CEtrainer.CTComboBox1.Left=30
CEtrainer.CTComboBox1.Top=50
CEtrainer.CTComboBox1.ReadOnly=true
CEtrainer.CTComboBox1.Style='csDropDownList'

CEtrainer.Btn1=createButton(frm1)
CEtrainer.Btn1.Left=140 CEtrainer.Btn1.Top=50
CEtrainer.Btn1.Caption="Samurai"

CEtrainer.Btn2=createButton(frm1)
CEtrainer.Btn2.Left=140 CEtrainer.Btn2.Top=80
CEtrainer.Btn2.Caption="Ashigaru"

CEtrainer.Btn3=createButton(frm1)
CEtrainer.Btn3.Left=140 CEtrainer.Btn3.Top=110
CEtrainer.Btn3.Caption="Archer"

CEtrainer.Btn4=createButton(frm1)
CEtrainer.Btn4.Left=140 CEtrainer.Btn4.Top=160
CEtrainer.Btn4.Caption="Value Update"

CEtrainer.Edt1=createEdit(frm1)
CEtrainer.Edt1.Left=50 CEtrainer.Edt1.Top=161

CEtrainer.Edt2=createEdit(frm1)
CEtrainer.Edt2.Left=30 CEtrainer.Edt2.Top=111

local condition = {
 Samurai = {"1:Samurai","11:Warrior Attack","182:Warrior Attack 2","215:Guard Break"},
 Ashigaru = {"3:Ashigaru","131:Ashigaru Attack","184:Ashigaru Attack 2"},
 Archer = {"13:Archer","31:Bow Attack","30:Bow Attack Plus","171:Yamamoto Sweeping Fire"}}

for i,k in pairs(condition) do
     for j,l in pairs(condition[i]) do
       l1 = l:match(":(.*)")
       CEtrainer.CTComboBox1.Items.Add(l1)
     end
end
CEtrainer.CTComboBox1.ItemIndex=0

getMemRecByDesc = getAddressList().getMemoryRecordByDescription
local CheatEdt1

function Samurai()
CheatEdt1=getMemRecByDesc("Main Attack")
CEtrainer.Edt2.Text = CheatEdt1.Value
CEtrainer.CTComboBox1.Clear()
 for i,k in pairs(condition.Samurai) do
   k1 = k:match(":(.*)")
  CEtrainer.CTComboBox1.Items.Add(k1)
 end
CEtrainer.CTComboBox1.ItemIndex=0
end

function Ashigaru()
CheatEdt1=getMemRecByDesc("Special Attack")
CEtrainer.Edt2.Text = CheatEdt1.Value
CEtrainer.CTComboBox1.Clear()
 for i,k in pairs(condition.Ashigaru) do
   k1 = k:match(":(.*)")
  CEtrainer.CTComboBox1.Items.Add(k1)
 end
CEtrainer.CTComboBox1.ItemIndex=0
end

function Archer()
CheatEdt1=getMemRecByDesc("Passive Skill")
CEtrainer.Edt2.Text = CheatEdt1.Value
CEtrainer.CTComboBox1.Clear()
 for i,k in pairs(condition.Archer) do
   k1 = k:match(":(.*)")
  CEtrainer.CTComboBox1.Items.Add(k1)
 end
CEtrainer.CTComboBox1.ItemIndex=0
end

CEtrainer.CTComboBox1.OnChange=function()
  if CEtrainer.CTComboBox1.ItemIndex==0 then
    CEtrainer.CTComboBox1.Clear()
    for i,k in pairs(condition) do
     for j,l in pairs(condition[i]) do
       l1 = l:match(":(.*)")
       CEtrainer.CTComboBox1.Items.Add(l1)
     end
    end
    CEtrainer.CTComboBox1.ItemIndex=0
  end
  for i,k in pairs(condition) do
     for j,l in pairs(condition[i]) do
       l1,l2 = l:match("(.*):(.*)")
        l3 = CEtrainer.CTComboBox1.Items[CEtrainer.CTComboBox1.ItemIndex]
        if l2==l3 then
         CheatEdt1.Value=l1 -- string = l2
         CEtrainer.Edt2.Text = CheatEdt1.Value
         print("Value: "..l1.."\nName: "..l2)
        end
     end
  end
end

function searchValue()
local val = CEtrainer.Edt1.Text
local tbl
local res = 0
 if CEtrainer.Edt1.Text~="" then
  for i,k in pairs(condition) do
     for j,l in pairs(condition[i]) do
       l1 = l:match("(.*):")
        if l1==val then
         tbl=condition[i]
         res=1
        end
     end
  end
 else
   showMessage("Please write a value in the box!")
 end
    if res==1 then
      CEtrainer.CTComboBox1.Clear()
      for i,k in pairs(tbl) do
        k1 = k:match(":(.*)")
        CEtrainer.CTComboBox1.Items.Add(k1)
      end
        CEtrainer.CTComboBox1.ItemIndex=0
    else
      showMessage("The specified value was not found!")
    end
end

CEtrainer.Btn1.OnClick=Samurai
CEtrainer.Btn2.OnClick=Ashigaru
CEtrainer.Btn3.OnClick=Archer
CEtrainer.Btn4.OnClick=searchValue

_________________
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
buyx86
Advanced Cheater
Reputation: 0

Joined: 10 May 2011
Posts: 82
Location: Philippines

PostPosted: Thu May 02, 2024 9:14 am    Post subject: Reply with quote

After continuous researching, I understood that what I wanted to do was impossible. The only way I can achieve what I want is through lua coding only. I was trying to do everything on AOB. I'll study your codes and see if I can learn how to do this. Thanks for all the help.
Back to top
View user's profile Send private message Yahoo 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