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 


Edit box and radio groups
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Jan 28, 2022 10:07 am    Post subject: Edit box and radio groups Reply with quote

After reading the documentation linked in another thread, and using ver. 7.3

Editvalue:string - The string of the optional edit field

So if I have an edit box named HeroOne then an string edit of that box would be
HeroOne.Editvalue = some string? But that isn't working as I have two different occurrences of edit boxes.
1. After entering a number in an edit box I have code translating this string to a number:value = tonumber(self.exp_value.Text); further in the code I attempted to clear the edit box with trainer.exp_value.Editvalue = ""; or trainer.exp_value.Text = ""; and neither clears the edit box. What is the correct syntax?

2. trainer.HeroOne.Editvalue = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Hero 1 Level")) That doesn't work either, what is the correct syntax?

Secondly I have a radio group, only one. Using a data table at the beginning of the code.
[0] = "Hero 1";
[1] = "Hero 2";
[2] = "Hero 3";
[3] = "Hero 4";
[4] = "No One";
There is other data that is loaded from a list view after one of the radios is selected. That all works. I want to set the radio group to "No One". The name of the radio is profession_rg. The documentation indicates
setItemIndex(integer), however trainer.characters_rg.setItemIndex(4) doesn't set the radio goup to "no One. WHat is the correct syntax here?
Back to top
View user's profile Send private message Yahoo Messenger
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Fri Jan 28, 2022 12:05 pm    Post subject: Reply with quote

Not sure where you're getting "Editvalue", but to get/set the text of an edit class object you use "Text". And in Lua the colon is used as a way to pass the object/table to a function. But because CE uses Pascal and thus the objects tend to be userdata you don't use a colon for a lot of things. Thus for an edit class object you'd use something like this.
Code:
trainer.HeroOne.Text = 'some text'


And I'd use the OOP syntax for the memory record too.
Code:
trainer.HeroOne.Text = AddressList.getMemoryRecordByDescription("Hero 1 Level").Value


And the radiogroup class uses a "Strings" class object for the Items, not a data table. Might be that the "Items" isn't set correctly.

EDIT:
You could also set a radio button manually then use "getItemIndex()" to see what it returns and that might help you figure out what's going on.

_________________
Back to top
View user's profile Send private message Visit poster's website
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Jan 28, 2022 1:26 pm    Post subject: Reply with quote

TheyCallMeTim13 wrote:
Not sure where you're getting "Editvalue", but to get/set the text of an edit class object you use "Text". And in Lua the colon is used as a way to pass the object/table to a function. But because CE uses Pascal and thus the objects tend to be userdata you don't use a colon for a lot of things. Thus for an edit class object you'd use something like this.
Code:
trainer.HeroOne.Text = 'some text'


And I'd use the OOP syntax for the memory record too.
Code:
trainer.HeroOne.Text = AddressList.getMemoryRecordByDescription("Hero 1 Level").Value


And the radiogroup class uses a "Strings" class object for the Items, not a data table. Might be that the "Items" isn't set correctly.

EDIT:
You could also set a radio button manually then use "getItemIndex()" to see what it returns and that might help you figure out what's going on.

Then tell me why trainer.exp_value.Text = "" doesn't clear the edit box?
Where did I get Editvalue, I copied it from the descriptions page.
Editvalue:string - The string of the optional edit field Line 2075.
I guess I didn't decribe the radio gropu correctly. When a radio is selected a corresponding list view set of data becomes visible. The radio uses the 5 elements in my first post. The question was how to set the radio to "No One" because I have trainer.characters_rg.setItemIndex(4) in my code and it does not set it to "No One", previous version of CE did with that command.

ETA: Nevermind, I stopped using 7.3 and reverted to 6.4 and eveything works as intended.
Thanks for your time.



2022-01-28_13-27-11.png
 Description:
 Filesize:  33.7 KB
 Viewed:  2808 Time(s)

2022-01-28_13-27-11.png


Back to top
View user's profile Send private message Yahoo Messenger
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Fri Jan 28, 2022 9:39 pm    Post subject: Reply with quote

Code:
trainer.characters_rg.ItemIndex=-1 -- no select

trainer.characters_rg.ItemIndex=0 --list select 1

trainer.characters_rg.ItemIndex=1 --list select 2



Code:
trainer =    {
            Data =    {
                   Characters = {
                                          [0] = "Zidane"; -- We will append the characters to the groupbox using value index.
                                          [1] = "Vivi";
                                          [2] = "Garnet";
                                          [3] = "Steiner";
                                          [4] = "Freya";
                                          [5] = "Quina";
                                          [6] = "Eiko";
                                          [7] = "Amarant";
                                          [8] = "No One";

                                          ["Zidane"] = 0;
                                          ["Vivi"] = 1;
                                          ["Garnet"] = 2;
                                          ["Steiner"] = 3;
                                          ["Freya"] = 4;
                                          ["Quina"] = 5;
                                          ["Eiko"] = 6;
                                          ["Amarant"] = 7;
                                          ["No One"] = 8;
                                          }}}
                        Stats =   { };
goldvalue = nil;
expvalue = nil;
heroname = nil;

function trainer:start()
   self.form = createForm(false); -- self = trainer since it's a function inside of a table...
   setProperty(self.form , "BiDiMode", "bdLeftToRight");
   self.form.Caption = 'Cheat Panel';
   self.form.Width = 450;
   self.form.Height = 360;
   self.form.Left = 340;
   self.form.Top =7;
   --
   self.value_panel2 = createPanel(self.form);
   self.value_panel2.Caption = '';
   self.value_panel2.left = 5;
   self.value_panel2.top = 7;
   self.value_panel2.Height = 40;
   self.value_panel2.Width = 93;
--
   self.value_panel1 = createPanel(self.form);
   self.value_panel1.Caption = '';
   self.value_panel1.left = 5;
   self.value_panel1.top = 50;
   self.value_panel1.Height = 40;
   self.value_panel1.Width = 93;
   --
   self.gold_value = createEdit(self.value_panel2);
   self.gold_value.top = 6;
   self.gold_value.left = 6;
   self.gold_value.Width = 80;
   self.gold_value.Height = 23;
   -- The line below this, allows only numbers or the - number to be entered.
   setMethodProperty(self.gold_value, "OnKeyPress", function (sender, key) local keynr = string.byte(key); if (keynr~=8) and (keynr~=45) and (keynr~=13) and ((keynr<48) or (keynr>57)) then key=nil; end if (keynr==13 and not(sender.Caption == nil or sender.Caption == '')) then key = nil; self.set_gold.onClick(); end return key; end)
--
   self.exp_value = createEdit(self.value_panel1);
   self.exp_value.top = 6;
   self.exp_value.left = 6;
   self.exp_value.Width = 80;
   self.exp_value.Height = 23;
   -- The line below this, allows only numbers or the - number to be entered.
   setMethodProperty(self.exp_value, "OnKeyPress", function (sender, key) local keynr = string.byte(key); if (keynr~=8) and (keynr~=45) and (keynr~=13) and ((keynr<48) or (keynr>57)) then key=nil; end if (keynr==13 and not(sender.Caption == nil or sender.Caption == '')) then key = nil; self.set_exp.onClick(); end return key; end)
--
   self.set_gold = createButton(self.form);
   self.set_gold.Caption = 'Enter Gold';
   self.set_gold.height = 35;
   self.set_gold.left = 100;
   self.set_gold.top = 7;
   self.set_gold.width = 150;
   self.set_gold.onClick =    function (sender)
                              local value = tonumber(self.gold_value.Caption);
                              if value then
                                 goldvalue = value;
                                 print("The gold value entered " .. goldvalue);
                                 --if expvalue and goldvalue and heroname then
                                 --   RecalculateAddresses()
                                 --end
                              end--if value then
                                self.gold_value.Caption = nil
                              end--function (sender)
--
   self.set_exp = createButton(self.form);
   self.set_exp.Caption = 'Enter Exp';
   self.set_exp.height = 35;
   self.set_exp.left = 100;
   self.set_exp.top = 52;
   self.set_exp.width = 150;
   self.set_exp.onClick =    function (sender)
                              local value = tonumber(self.exp_value.Caption);
                              if value then
                                 expvalue = value;
                                 print("The exp value entered " .. goldvalue);
                                 --if expvalue and goldvalue and heroname then
                                  --  RecalculateAddresses()
                                 --end
                              end--if value then
                                self.exp_value.Caption = nil
                              end--function (sender)
--
  self.characters_rg = createRadioGroup(self.form)
  self.characters_rg.Caption = 'Characters:'
  self.characters_rg.AutoSize = true
  self.characters_rg.Columns = 1 -- two columns (default is 1)
--  characters_rg.Items.Text = 'Zidane\nVivi\nGarnet\nSteiner\nFreya\nQuina\nEiko\nAmarant\nNo One' -- delimited with \n
  self.characters_rg.setItemIndex(-1) -- select first option by default
  self.characters_rg.Top = 90
  self.characters_rg.Left = 5
  for character,_ in pairs(self.Data.Characters) do
    if tonumber(character) then
      self.characters_rg.getItems().add(_);
    end
  end--for character,_ in pairs(self.Data.Characters) do

--
  self.listview = createListView(self.form)
  setProperty(self.listview, 'ViewStyle', 'vsReport')
  setProperty(self.listview, 'RowSelect', 'True')
  setProperty(self.listview, 'ReadOnly', 'True')
  setProperty(self.listview, 'HideSelection', 'False')
  self.listview.top = 95;
  self.listview.width = 140;
  self.listview.left = 100;
  self.listview.height = 250;
  self.listview_colum1 = self.listview.getColumns().add()
  self.listview_colum1.Width = 40;
  self.listview_colum1.Caption = 'Lvl';
  self.listview_colum2 = self.listview.getColumns().add()
  self.listview_colum2.Width = 80;
  self.listview_colum2.Caption = 'Exp';

  self.listview.onClick = function (sender)
                              local char
                              if (self.characters_rg.ItemIndex >= 0 ) then
                                 char = strings_getString(self.characters_rg.getItems(), self.characters_rg.ItemIndex);
                              end
                              local row_1 = sender.getItems().getItem(sender.getItemIndex()); -- Level
                              local row_2 = strings_getString(row_1.getSubItems(),0) + 0; -- Exp
                              if (char and row_1 and row_2) then
                                 local address_1 = addresslist_getMemoryRecordByDescription(getAddressList(), char .. ' Exp');
                                 local address_2 = addresslist_getMemoryRecordByDescription(getAddressList(), char .. ' Exp 16^6');
                                 if (address_1 and address_2) then
                                    memoryrecord_setValue(address_1, row_2 - math.floor(row_2/65536) * 65536)
                                    memoryrecord_setValue(address_2, math.floor(row_2/65536))
                                 end
                              end
                              trainer.characters_rg.setItemIndex(8);
                           end--function (sender)

  self.characters_rg.onClick =    function (sender)--Need Character Data Table
                                    local index = strings_getString(sender.getItems(), sender.ItemIndex);
                                    local i = nil;
                                    i = self.Data.Characters[index] + 1; -- If the character does not hold the value,, i remains nil.
                                    if i then
                                       heroname = index;
                                       print("The index selected is", self.Data.Characters[index]);
                                       print("The hero name is ", heroname);
                                       if heroname == "No One" then  --for _,__table in pairs(self.Data.Stats[i]) do
                                         heroname = nil;
                                       else
                                       end;
                                    end;--if i then
                                    if expvalue and goldvalue and heroname then
                                       RecalculateAddresses();
                                    end;--if expvalue and goldvalue and heroname then
                                  end;--function (sender)
--

--
   self.set_exp1 = createButton(self.form);
   self.set_exp1.Caption = 'No Radio Select';
   self.set_exp1.height = 35;
   self.set_exp1.left = 280;
   self.set_exp1.top = 52;
   self.set_exp1.width = 150;
   self.set_exp1.onClick =    function (sender)
                                self.characters_rg.ItemIndex=-1
                                end

   self.form.show();
end;--function trainer:start()
--
function RecalculateAddresses(sender)

 local AL = getAddressList()
 local MS = createMemScan()
 local FL = createFoundList(MS)
   memscan_firstScan(MS,
   soExactValue, vtQword, rtRounded, goldvalue, "",
   0, 0xffffffffffffffff, "*X*C*W", fsmNotAligned, "",
   false, false, false, true)

 memscan_waitTillDone(MS)
 foundlist_initialize(FL)
 print("Num of Gold found ", foundlist_getCount(FL))

 for i = 0, foundlist_getCount(FL)-1  do
   local goldAddr_hex = foundlist_getAddress(FL, i) -- foundlist_getAddress always returns in hex without 0x
   --print("The address for Gold is ", goldAddr_hex)
   local goldAddr_dec = tonumber(goldAddr_hex, 16)   -- convert to decimal number
   --print("The num conversion for Gold address is ", goldAddr_dec)
   if string.sub(goldAddr_hex, -3) == "7EC" then
     correct_goldAddr_hex = goldAddr_hex
   end--if string.sub(memrec2, -3) == "7EC" then
 end--for i = 0, foundlist_getCount(FL)-1  do
   print("The correct address for Gold is ", correct_goldAddr_hex)
   local oldGoldAddr_hex = memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(AL, "Gold x 16^4"))
   --print("The old table address for Gold is ".. oldGoldAddr_hex)
   local correction = tonumber(correct_goldAddr_hex, 16) - oldGoldAddr_hex
   print("The correction is " .. correction)
   for j=0, addresslist_getCount(AL)-1 do
     local mr = addresslist_getMemoryRecord(AL, j)
     local newAddress = memoryrecord_getAddress(mr) + correction
     memoryrecord_setAddress(mr, string.format("%x", newAddress))
   end -- loop 'for j' end

   sleep(100)
   object_destroy(FL)
   object_destroy(MS)
   print("The table has been recalculated")

 end--function RecalculateAddresses(sender)
--
trainer:start();

print("help")


https://forum.cheatengine.org/viewtopic.php?p=1542043&sid=585a9d9622f08553fd1f99bb5006fc42
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri Jan 28, 2022 9:47 pm    Post subject: Reply with quote

ByTransient wrote:
Code:
trainer.characters_rg.ItemIndex=-1 -- no select

trainer.characters_rg.ItemIndex=0 --list select 1

trainer.characters_rg.ItemIndex=1 --list select 2



Code:
trainer =    {
            Data =    {
                   Characters = {
                                          [0] = "Zidane"; -- We will append the characters to the groupbox using value index.
                                          [1] = "Vivi";
                                          [2] = "Garnet";
                                          [3] = "Steiner";
                                          [4] = "Freya";
                                          [5] = "Quina";
                                          [6] = "Eiko";
                                          [7] = "Amarant";
                                          [8] = "No One";

                                          ["Zidane"] = 0;
                                          ["Vivi"] = 1;
                                          ["Garnet"] = 2;
                                          ["Steiner"] = 3;
                                          ["Freya"] = 4;
                                          ["Quina"] = 5;
                                          ["Eiko"] = 6;
                                          ["Amarant"] = 7;
                                          ["No One"] = 8;
                                          }}}
                        Stats =   { };
goldvalue = nil;
expvalue = nil;
heroname = nil;

function trainer:start()
   self.form = createForm(false); -- self = trainer since it's a function inside of a table...
   setProperty(self.form , "BiDiMode", "bdLeftToRight");
   self.form.Caption = 'Cheat Panel';
   self.form.Width = 450;
   self.form.Height = 360;
   self.form.Left = 340;
   self.form.Top =7;
   --
   self.value_panel2 = createPanel(self.form);
   self.value_panel2.Caption = '';
   self.value_panel2.left = 5;
   self.value_panel2.top = 7;
   self.value_panel2.Height = 40;
   self.value_panel2.Width = 93;
--
   self.value_panel1 = createPanel(self.form);
   self.value_panel1.Caption = '';
   self.value_panel1.left = 5;
   self.value_panel1.top = 50;
   self.value_panel1.Height = 40;
   self.value_panel1.Width = 93;
   --
   self.gold_value = createEdit(self.value_panel2);
   self.gold_value.top = 6;
   self.gold_value.left = 6;
   self.gold_value.Width = 80;
   self.gold_value.Height = 23;
   -- The line below this, allows only numbers or the - number to be entered.
   setMethodProperty(self.gold_value, "OnKeyPress", function (sender, key) local keynr = string.byte(key); if (keynr~=8) and (keynr~=45) and (keynr~=13) and ((keynr<48) or (keynr>57)) then key=nil; end if (keynr==13 and not(sender.Caption == nil or sender.Caption == '')) then key = nil; self.set_gold.onClick(); end return key; end)
--
   self.exp_value = createEdit(self.value_panel1);
   self.exp_value.top = 6;
   self.exp_value.left = 6;
   self.exp_value.Width = 80;
   self.exp_value.Height = 23;
   -- The line below this, allows only numbers or the - number to be entered.
   setMethodProperty(self.exp_value, "OnKeyPress", function (sender, key) local keynr = string.byte(key); if (keynr~=8) and (keynr~=45) and (keynr~=13) and ((keynr<48) or (keynr>57)) then key=nil; end if (keynr==13 and not(sender.Caption == nil or sender.Caption == '')) then key = nil; self.set_exp.onClick(); end return key; end)
--
   self.set_gold = createButton(self.form);
   self.set_gold.Caption = 'Enter Gold';
   self.set_gold.height = 35;
   self.set_gold.left = 100;
   self.set_gold.top = 7;
   self.set_gold.width = 150;
   self.set_gold.onClick =    function (sender)
                              local value = tonumber(self.gold_value.Caption);
                              if value then
                                 goldvalue = value;
                                 print("The gold value entered " .. goldvalue);
                                 --if expvalue and goldvalue and heroname then
                                 --   RecalculateAddresses()
                                 --end
                              end--if value then
                                self.gold_value.Caption = nil
                              end--function (sender)
--
   self.set_exp = createButton(self.form);
   self.set_exp.Caption = 'Enter Exp';
   self.set_exp.height = 35;
   self.set_exp.left = 100;
   self.set_exp.top = 52;
   self.set_exp.width = 150;
   self.set_exp.onClick =    function (sender)
                              local value = tonumber(self.exp_value.Caption);
                              if value then
                                 expvalue = value;
                                 print("The exp value entered " .. goldvalue);
                                 --if expvalue and goldvalue and heroname then
                                  --  RecalculateAddresses()
                                 --end
                              end--if value then
                                self.exp_value.Caption = nil
                              end--function (sender)
--
  self.characters_rg = createRadioGroup(self.form)
  self.characters_rg.Caption = 'Characters:'
  self.characters_rg.AutoSize = true
  self.characters_rg.Columns = 1 -- two columns (default is 1)
--  characters_rg.Items.Text = 'Zidane\nVivi\nGarnet\nSteiner\nFreya\nQuina\nEiko\nAmarant\nNo One' -- delimited with \n
  self.characters_rg.setItemIndex(-1) -- select first option by default
  self.characters_rg.Top = 90
  self.characters_rg.Left = 5
  for character,_ in pairs(self.Data.Characters) do
    if tonumber(character) then
      self.characters_rg.getItems().add(_);
    end
  end--for character,_ in pairs(self.Data.Characters) do

--
  self.listview = createListView(self.form)
  setProperty(self.listview, 'ViewStyle', 'vsReport')
  setProperty(self.listview, 'RowSelect', 'True')
  setProperty(self.listview, 'ReadOnly', 'True')
  setProperty(self.listview, 'HideSelection', 'False')
  self.listview.top = 95;
  self.listview.width = 140;
  self.listview.left = 100;
  self.listview.height = 250;
  self.listview_colum1 = self.listview.getColumns().add()
  self.listview_colum1.Width = 40;
  self.listview_colum1.Caption = 'Lvl';
  self.listview_colum2 = self.listview.getColumns().add()
  self.listview_colum2.Width = 80;
  self.listview_colum2.Caption = 'Exp';

  self.listview.onClick = function (sender)
                              local char
                              if (self.characters_rg.ItemIndex >= 0 ) then
                                 char = strings_getString(self.characters_rg.getItems(), self.characters_rg.ItemIndex);
                              end
                              local row_1 = sender.getItems().getItem(sender.getItemIndex()); -- Level
                              local row_2 = strings_getString(row_1.getSubItems(),0) + 0; -- Exp
                              if (char and row_1 and row_2) then
                                 local address_1 = addresslist_getMemoryRecordByDescription(getAddressList(), char .. ' Exp');
                                 local address_2 = addresslist_getMemoryRecordByDescription(getAddressList(), char .. ' Exp 16^6');
                                 if (address_1 and address_2) then
                                    memoryrecord_setValue(address_1, row_2 - math.floor(row_2/65536) * 65536)
                                    memoryrecord_setValue(address_2, math.floor(row_2/65536))
                                 end
                              end
                              trainer.characters_rg.setItemIndex(8);
                           end--function (sender)

  self.characters_rg.onClick =    function (sender)--Need Character Data Table
                                    local index = strings_getString(sender.getItems(), sender.ItemIndex);
                                    local i = nil;
                                    i = self.Data.Characters[index] + 1; -- If the character does not hold the value,, i remains nil.
                                    if i then
                                       heroname = index;
                                       print("The index selected is", self.Data.Characters[index]);
                                       print("The hero name is ", heroname);
                                       if heroname == "No One" then  --for _,__table in pairs(self.Data.Stats[i]) do
                                         heroname = nil;
                                       else
                                       end;
                                    end;--if i then
                                    if expvalue and goldvalue and heroname then
                                       RecalculateAddresses();
                                    end;--if expvalue and goldvalue and heroname then
                                  end;--function (sender)
--

--
   self.set_exp1 = createButton(self.form);
   self.set_exp1.Caption = 'No Radio Select';
   self.set_exp1.height = 35;
   self.set_exp1.left = 280;
   self.set_exp1.top = 52;
   self.set_exp1.width = 150;
   self.set_exp1.onClick =    function (sender)
                                self.characters_rg.ItemIndex=-1
                                end

   self.form.show();
end;--function trainer:start()
--
function RecalculateAddresses(sender)

 local AL = getAddressList()
 local MS = createMemScan()
 local FL = createFoundList(MS)
   memscan_firstScan(MS,
   soExactValue, vtQword, rtRounded, goldvalue, "",
   0, 0xffffffffffffffff, "*X*C*W", fsmNotAligned, "",
   false, false, false, true)

 memscan_waitTillDone(MS)
 foundlist_initialize(FL)
 print("Num of Gold found ", foundlist_getCount(FL))

 for i = 0, foundlist_getCount(FL)-1  do
   local goldAddr_hex = foundlist_getAddress(FL, i) -- foundlist_getAddress always returns in hex without 0x
   --print("The address for Gold is ", goldAddr_hex)
   local goldAddr_dec = tonumber(goldAddr_hex, 16)   -- convert to decimal number
   --print("The num conversion for Gold address is ", goldAddr_dec)
   if string.sub(goldAddr_hex, -3) == "7EC" then
     correct_goldAddr_hex = goldAddr_hex
   end--if string.sub(memrec2, -3) == "7EC" then
 end--for i = 0, foundlist_getCount(FL)-1  do
   print("The correct address for Gold is ", correct_goldAddr_hex)
   local oldGoldAddr_hex = memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(AL, "Gold x 16^4"))
   --print("The old table address for Gold is ".. oldGoldAddr_hex)
   local correction = tonumber(correct_goldAddr_hex, 16) - oldGoldAddr_hex
   print("The correction is " .. correction)
   for j=0, addresslist_getCount(AL)-1 do
     local mr = addresslist_getMemoryRecord(AL, j)
     local newAddress = memoryrecord_getAddress(mr) + correction
     memoryrecord_setAddress(mr, string.format("%x", newAddress))
   end -- loop 'for j' end

   sleep(100)
   object_destroy(FL)
   object_destroy(MS)
   print("The table has been recalculated")

 end--function RecalculateAddresses(sender)
--
trainer:start();

print("help")


https://forum.cheatengine.org/viewtopic.php?p=1542043&sid=585a9d9622f08553fd1f99bb5006fc42


What is this ??? Shocked Shocked

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Sat Jan 29, 2022 7:33 am    Post subject: Reply with quote

Corroder wrote:
ByTransient wrote:
Code:
trainer.characters_rg.ItemIndex=-1 -- no select

trainer.characters_rg.ItemIndex=0 --list select 1

trainer.characters_rg.ItemIndex=1 --list select 2




https://forum.cheatengine.org/viewtopic.php?p=1542043&sid=585a9d9622f08553fd1f99bb5006fc42


What is this ??? Shocked Shocked


Probably the original post.
And previous solution notes.

Just like highlighting the alternative "ItemIndex=-1" for "No One".
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sat Jan 29, 2022 9:12 am    Post subject: Reply with quote

The problem was using version 7.3 trainer.characters_rg.setItemIndex(4); doesn't work to set the rg to item 4 in my example. Using version 6.4 it works.
That is why I said never mind in my last ETA. The problem with both of my newest posts all stemmed from using version 7.3, and DB hinted at the solution, but never outright came out and stated the issues 64 bit versus 32 bit. No more updates for me as I'm using 32 bit games.
Back to top
View user's profile Send private message Yahoo Messenger
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

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

PostPosted: Sat Jan 29, 2022 9:42 am    Post subject: Reply with quote

bknight2602 wrote:
trainer.characters_rg.setItemIndex(4); doesn't work to set the rg to item 4 in my example.


This won't select item 4 because the entries are 0-based. In other words, 0 = 1, 1 = 2, 3 = 4 and so on...

Here is an example: First, create a new UDF form, add a RadioGroup and a Label to the form.

Set the names of the components as follows;
    Label = lblSelected
    RadioGroup = CERadioGroup1
    UDF form = UDF1


Then in the CERadioGroup onClick event use this code:
Code:

function UDF1_CERadioGroup1Click(sender)
         UDF1.lblSelected.Caption = 'Item selected : ' .. tostring(UDF1.CERadioGroup1.ItemIndex)
end


When changing the RadioGroup item, the label will display the index of the selected item.
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Sat Jan 29, 2022 10:26 am    Post subject: Reply with quote

bknight2602 wrote:
The problem was using version 7.3 trainer.characters_rg.setItemIndex(4); doesn't work to set the rg to item 4 in my example. Using version 6.4 it works.
That is why I said never mind in my last ETA. The problem with both of my newest posts all stemmed from using version 7.3, and DB hinted at the solution, but never outright came out and stated the issues 64 bit versus 32 bit. No more updates for me as I'm using 32 bit games.



https://forum.cheatengine.org/viewtopic.php?p=5776497#5776497

This code works fine in 7.4.

Copy it and try on 7.4.

Yes, some builds may not work in 7.2 and 7.3.
7.4 is a more stable version.
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Jan 30, 2022 10:00 am    Post subject: Reply with quote

LeFiXER wrote:
bknight2602 wrote:
trainer.characters_rg.setItemIndex(4); doesn't work to set the rg to item 4 in my example.


This won't select item 4 because the entries are 0-based. In other words, 0 = 1, 1 = 2, 3 = 4 and so on...

Here is an example: First, create a new UDF form, add a RadioGroup and a Label to the form.

Set the names of the components as follows;
    Label = lblSelected
    RadioGroup = CERadioGroup1
    UDF form = UDF1


Then in the CERadioGroup onClick event use this code:
Code:

function UDF1_CERadioGroup1Click(sender)
         UDF1.lblSelected.Caption = 'Item selected : ' .. tostring(UDF1.CERadioGroup1.ItemIndex)
end


When changing the RadioGroup item, the label will display the index of the selected item.


Yes, and if you would look at one of the images of the trainer I poster you will see 5 items "No One" is item five with an index of 4. This works in version 6.4.
Back to top
View user's profile Send private message Yahoo Messenger
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

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

PostPosted: Sun Jan 30, 2022 10:43 am    Post subject: Reply with quote

bknight2602 wrote:

trainer.characters_rg.setItemIndex(4); doesn't work to set the rg to item 4 in my example.
...
Yes, and if you would look at one of the images of the trainer I poster you will see 5 items "No One" is item five with an index of 4. This works in version 6.4.


Precisely my point. Why would this:
Code:

trainer.characters_rg.setItemIndex(4);

Select Hero 4 (which happens to be the fourth item)? It won't because the first item is index 0, second item is index 1, third item is index 2 and so on. I'm not here to ridicule you. I am just showing the something that you may have overlooked which could be the cause of your issue.

I fail to reproduce the issue you're having with CE 7.4. Steps I took:


    1) Created form via menu
    2) Added an edit box, radiogroup and a button to the form
    3) Added the same entries to the radiogroup (Hero 1, Hero 2, Hero 3 etc...)
    4) In the OnClick event of the button I used the following code:
    Code:

    function UDF1_CEToggleBox1Click(sender)
       UDF1.CEEdit1.Text = ''
       UDF1.CERadioGroup1.setItemIndex(4)
    end

    5) I clicked execute, closed the form designer and then clicked the button
    6) As expected, the text field cleared and the radio item "No One" was selected


See: Demonstration
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Jan 30, 2022 10:30 pm    Post subject: Reply with quote

LeFiXER wrote:
bknight2602 wrote:

trainer.characters_rg.setItemIndex(4); doesn't work to set the rg to item 4 in my example.
...
Yes, and if you would look at one of the images of the trainer I poster you will see 5 items "No One" is item five with an index of 4. This works in version 6.4.


Precisely my point. Why would this:
Code:

trainer.characters_rg.setItemIndex(4);

Select Hero 4 (which happens to be the fourth item)? It won't because the first item is index 0, second item is index 1, third item is index 2 and so on. I'm not here to ridicule you. I am just showing the something that you may have overlooked which could be the cause of your issue.
I'm not expecting index 4 to select hero 4, where did I give you that impression? I wanted No One, but the real issue was it didn't work. The hero that was selected to do the calculation was still selected after trainer.characters_rg.setItemIndex(4) and in this case Hero 1 was selected.
Quote:


I fail to reproduce the issue you're having with CE 7.4. Steps I took:


    1) Created form via menu
    2) Added an edit box, radiogroup and a button to the form
    3) Added the same entries to the radiogroup (Hero 1, Hero 2, Hero 3 etc...)
    4) In the OnClick event of the button I used the following code:
    Code:

    function UDF1_CEToggleBox1Click(sender)
       UDF1.CEEdit1.Text = ''
       UDF1.CERadioGroup1.setItemIndex(4)
    end

    5) I clicked execute, closed the form designer and then clicked the button
    6) As expected, the text field cleared and the radio item "No One" was selected


See: Demonstration


I don't have the issue with 6.3 or 6.7 (two machines), I did with 7.3. As I indicated when the version is available i'll download it and give it a try.
Back to top
View user's profile Send private message Yahoo Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Mon Feb 14, 2022 11:43 am    Post subject: Reply with quote

I have one more question. If the character selected is "No One" I would like the listview hidden. I tried Trainer.listview.hide But only received this error message
Script Error:[string "trainer.listview.hide
..."]:2: syntax error near <eof>
What would be the correct coommand to hide the listview?
Back to top
View user's profile Send private message Yahoo Messenger
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

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

PostPosted: Mon Feb 14, 2022 11:55 am    Post subject: Reply with quote

What code do you have so far?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Mon Feb 14, 2022 12:12 pm    Post subject: Reply with quote

listview.Visible=false
_________________
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
View user's profile Send private message 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
Goto page 1, 2  Next
Page 1 of 2

 
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