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 


Why does a table work on one lap and not another?

 
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: 586

PostPosted: Mon Mar 07, 2016 10:53 am    Post subject: Why does a table work on one lap and not another? Reply with quote

Code:

trainer =    {
            Data =    {
                   Characters = {
                                          [0] = "Zidane"; -- Table auto selects characters based alphabet order... so 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; -- Index of radiogroup
                                          ["Vivi"] = 1;
                                          ["Garnet"] = 2;
                                          ["Steiner"] = 3;
                                          ["Freya"] = 4;
                                          ["Quina"] = 5;
                                          ["Eiko"] = 6;
                                          ["Amarant"] = 7;
                                          ["No One"] = 8;
                        Stats =   { -- Exp and level
                                    {{1,15};{2,46};{3,100};{4,185};{5,313};{6,495};{7,745};{8,1077};{9,1509};{10,2058};{11,2744};{12,3587};{13,4611};{14,5839};{15,7297};{16,9011};{17,11011};{18,13326};{19,15988};{20,19029};{21,22485};{22,26391};{23,30785};{24,35705};{25,41193};{26,47290};{27,54040};{28,61487};{29,69679};{30,78663};{31,88489};{32,99207};{33,110871};{34,123534};{35,137232};{36,152081};{37,168081};{38,185311};{39,203833};{40,223709};{41,244005};{42,267786};{43,292120};{44,318075};{45,344723};{46,375135};{47,406385};{48,439547};{49,474699};{50,511918};{51,551284};{52,592877};{53,636781};{54,683079};{55,731857};{56,783201};{57,837201};{58,893946};{59,953528};{60,1016039};{61,1081575};{62,1150231};{63,1222105};{64,1297295};{65,1375903};{66,1458030};{67,1543780};{68,1633257};{69,1726569};{70,1823823};{71,1925129};{72,2030597};{73,2140341};{74,2254474};{75,2373112};{76,2496371};{77,2624371};{78,2757231};{79,2895073};{79,2895073};{80,3038019};{81,3186195};{82,3339726};{83,3498740};{84,3663365};{85,3833733};{86,4009975};{87,4192225};{88,4380617};{89,4575289};{90,4776378};{91,4984024};{92,5198367};{93,5419551};{94,5647719};{95,5883017};{96,6125591};{97,6375591};{98,6633166};};
                                    {{1,15};{2,46};{3,100};{4,185};{5,313};{6,495};{7,745};{8,1077};{9,1509};{10,2058};{11,2744};{12,3587};{13,4611};{14,5839};{15,7297};{16,9011};{17,11011};{18,13326};{19,15988};{20,19029};{21,22485};{22,26391};{23,30785};{24,35705};{25,41193};{26,47290};{27,54040};{28,61487};{29,69679};{30,78663};{31,88489};{32,99207};{33,110871};{34,123534};{35,137232};{36,152081};{37,168081};{38,185311};{39,203833};{40,223709};{41,244005};{42,267786};{43,292120};{44,318075};{45,344723};{46,375135};{47,406385};{48,439547};{49,474699};{50,511918};{51,551284};{52,592877};{53,636781};{54,683079};{55,731857};{56,783201};{57,837201};{58,893946};{59,953528};{60,1016039};{61,1081575};{62,1150231};{63,1222105};{64,1297295};{65,1375903};{66,1458030};{67,1543780};{68,1633257};{69,1726569};{70,1823823};{71,1925129};{72,2030597};{73,2140341};{74,2254474};{75,2373112};{76,2496371};{77,2624371};{78,2757231};{79,2895073};{79,2895073};{80,3038019};{81,3186195};{82,3339726};{83,3498740};{84,3663365};{85,3833733};{86,4009975};{87,4192225};{88,4380617};{89,4575289};{90,4776378};{91,4984024};{92,5198367};{93,5419551};{94,5647719};{95,5883017};{96,6125591};{97,6375591};{98,6633166};};
                                    {{1,15};{2,46};{3,100};{4,185};{5,313};{6,495};{7,745};{8,1077};{9,1509};{10,2058};{11,2744};{12,3587};{13,4611};{14,5839};{15,7297};{16,9011};{17,11011};{18,13326};{19,15988};{20,19029};{21,22485};{22,26391};{23,30785};{24,35705};{25,41193};{26,47290};{27,54040};{28,61487};{29,69679};{30,78663};{31,88489};{32,99207};{33,110871};{34,123534};{35,137232};{36,152081};{37,168081};{38,185311};{39,203833};{40,223709};{41,244005};{42,267786};{43,292120};{44,318075};{45,344723};{46,375135};{47,406385};{48,439547};{49,474699};{50,511918};{51,551284};{52,592877};{53,636781};{54,683079};{55,731857};{56,783201};{57,837201};{58,893946};{59,953528};{60,1016039};{61,1081575};{62,1150231};{63,1222105};{64,1297295};{65,1375903};{66,1458030};{67,1543780};{68,1633257};{69,1726569};{70,1823823};{71,1925129};{72,2030597};{73,2140341};{74,2254474};{75,2373112};{76,2496371};{77,2624371};{78,2757231};{79,2895073};{79,2895073};{80,3038019};{81,3186195};{82,3339726};{83,3498740};{84,3663365};{85,3833733};{86,4009975};{87,4192225};{88,4380617};{89,4575289};{90,4776378};{91,4984024};{92,5198367};{93,5419551};{94,5647719};{95,5883017};{96,6125591};{97,6375591};{98,6633166};};
                                    {{1,15};{2,46};{3,100};{4,185};{5,313};{6,495};{7,745};{8,1077};{9,1509};{10,2058};{11,2744};{12,3587};{13,4611};{14,5839};{15,7297};{16,9011};{17,11011};{18,13326};{19,15988};{20,19029};{21,22485};{22,26391};{23,30785};{24,35705};{25,41193};{26,47290};{27,54040};{28,61487};{29,69679};{30,78663};{31,88489};{32,99207};{33,110871};{34,123534};{35,137232};{36,152081};{37,168081};{38,185311};{39,203833};{40,223709};{41,244005};{42,267786};{43,292120};{44,318075};{45,344723};{46,375135};{47,406385};{48,439547};{49,474699};{50,511918};{51,551284};{52,592877};{53,636781};{54,683079};{55,731857};{56,783201};{57,837201};{58,893946};{59,953528};{60,1016039};{61,1081575};{62,1150231};{63,1222105};{64,1297295};{65,1375903};{66,1458030};{67,1543780};{68,1633257};{69,1726569};{70,1823823};{71,1925129};{72,2030597};{73,2140341};{74,2254474};{75,2373112};{76,2496371};{77,2624371};{78,2757231};{79,2895073};{79,2895073};{80,3038019};{81,3186195};{82,3339726};{83,3498740};{84,3663365};{85,3833733};{86,4009975};{87,4192225};{88,4380617};{89,4575289};{90,4776378};{91,4984024};{92,5198367};{93,5419551};{94,5647719};{95,5883017};{96,6125591};{97,6375591};{98,6633166};};
                                    {{1,15};{2,46};{3,100};{4,185};{5,313};{6,495};{7,745};{8,1077};{9,1509};{10,2058};{11,2744};{12,3587};{13,4611};{14,5839};{15,7297};{16,9011};{17,11011};{18,13326};{19,15988};{20,19029};{21,22485};{22,26391};{23,30785};{24,35705};{25,41193};{26,47290};{27,54040};{28,61487};{29,69679};{30,78663};{31,88489};{32,99207};{33,110871};{34,123534};{35,137232};{36,152081};{37,168081};{38,185311};{39,203833};{40,223709};{41,244005};{42,267786};{43,292120};{44,318075};{45,344723};{46,375135};{47,406385};{48,439547};{49,474699};{50,511918};{51,551284};{52,592877};{53,636781};{54,683079};{55,731857};{56,783201};{57,837201};{58,893946};{59,953528};{60,1016039};{61,1081575};{62,1150231};{63,1222105};{64,1297295};{65,1375903};{66,1458030};{67,1543780};{68,1633257};{69,1726569};{70,1823823};{71,1925129};{72,2030597};{73,2140341};{74,2254474};{75,2373112};{76,2496371};{77,2624371};{78,2757231};{79,2895073};{79,2895073};{80,3038019};{81,3186195};{82,3339726};{83,3498740};{84,3663365};{85,3833733};{86,4009975};{87,4192225};{88,4380617};{89,4575289};{90,4776378};{91,4984024};{92,5198367};{93,5419551};{94,5647719};{95,5883017};{96,6125591};{97,6375591};{98,6633166};};
                                    {{1,15};{2,46};{3,100};{4,185};{5,313};{6,495};{7,745};{8,1077};{9,1509};{10,2058};{11,2744};{12,3587};{13,4611};{14,5839};{15,7297};{16,9011};{17,11011};{18,13326};{19,15988};{20,19029};{21,22485};{22,26391};{23,30785};{24,35705};{25,41193};{26,47290};{27,54040};{28,61487};{29,69679};{30,78663};{31,88489};{32,99207};{33,110871};{34,123534};{35,137232};{36,152081};{37,168081};{38,185311};{39,203833};{40,223709};{41,244005};{42,267786};{43,292120};{44,318075};{45,344723};{46,375135};{47,406385};{48,439547};{49,474699};{50,511918};{51,551284};{52,592877};{53,636781};{54,683079};{55,731857};{56,783201};{57,837201};{58,893946};{59,953528};{60,1016039};{61,1081575};{62,1150231};{63,1222105};{64,1297295};{65,1375903};{66,1458030};{67,1543780};{68,1633257};{69,1726569};{70,1823823};{71,1925129};{72,2030597};{73,2140341};{74,2254474};{75,2373112};{76,2496371};{77,2624371};{78,2757231};{79,2895073};{79,2895073};{80,3038019};{81,3186195};{82,3339726};{83,3498740};{84,3663365};{85,3833733};{86,4009975};{87,4192225};{88,4380617};{89,4575289};{90,4776378};{91,4984024};{92,5198367};{93,5419551};{94,5647719};{95,5883017};{96,6125591};{97,6375591};{98,6633166};};
                                    {{1,15};{2,46};{3,100};{4,185};{5,313};{6,495};{7,745};{8,1077};{9,1509};{10,2058};{11,2744};{12,3587};{13,4611};{14,5839};{15,7297};{16,9011};{17,11011};{18,13326};{19,15988};{20,19029};{21,22485};{22,26391};{23,30785};{24,35705};{25,41193};{26,47290};{27,54040};{28,61487};{29,69679};{30,78663};{31,88489};{32,99207};{33,110871};{34,123534};{35,137232};{36,152081};{37,168081};{38,185311};{39,203833};{40,223709};{41,244005};{42,267786};{43,292120};{44,318075};{45,344723};{46,375135};{47,406385};{48,439547};{49,474699};{50,511918};{51,551284};{52,592877};{53,636781};{54,683079};{55,731857};{56,783201};{57,837201};{58,893946};{59,953528};{60,1016039};{61,1081575};{62,1150231};{63,1222105};{64,1297295};{65,1375903};{66,1458030};{67,1543780};{68,1633257};{69,1726569};{70,1823823};{71,1925129};{72,2030597};{73,2140341};{74,2254474};{75,2373112};{76,2496371};{77,2624371};{78,2757231};{79,2895073};{79,2895073};{80,3038019};{81,3186195};{82,3339726};{83,3498740};{84,3663365};{85,3833733};{86,4009975};{87,4192225};{88,4380617};{89,4575289};{90,4776378};{91,4984024};{92,5198367};{93,5419551};{94,5647719};{95,5883017};{96,6125591};{97,6375591};{98,6633166};};
                                    {{1,15};{2,46};{3,100};{4,185};{5,313};{6,495};{7,745};{8,1077};{9,1509};{10,2058};{11,2744};{12,3587};{13,4611};{14,5839};{15,7297};{16,9011};{17,11011};{18,13326};{19,15988};{20,19029};{21,22485};{22,26391};{23,30785};{24,35705};{25,41193};{26,47290};{27,54040};{28,61487};{29,69679};{30,78663};{31,88489};{32,99207};{33,110871};{34,123534};{35,137232};{36,152081};{37,168081};{38,185311};{39,203833};{40,223709};{41,244005};{42,267786};{43,292120};{44,318075};{45,344723};{46,375135};{47,406385};{48,439547};{49,474699};{50,511918};{51,551284};{52,592877};{53,636781};{54,683079};{55,731857};{56,783201};{57,837201};{58,893946};{59,953528};{60,1016039};{61,1081575};{62,1150231};{63,1222105};{64,1297295};{65,1375903};{66,1458030};{67,1543780};{68,1633257};{69,1726569};{70,1823823};{71,1925129};{72,2030597};{73,2140341};{74,2254474};{75,2373112};{76,2496371};{77,2624371};{78,2757231};{79,2895073};{79,2895073};{80,3038019};{81,3186195};{82,3339726};{83,3498740};{84,3663365};{85,3833733};{86,4009975};{87,4192225};{88,4380617};{89,4575289};{90,4776378};{91,4984024};{92,5198367};{93,5419551};{94,5647719};{95,5883017};{96,6125591};{97,6375591};{98,6633166};};
                                    {};
                                   };
                                };
                      };
             };
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 = 835;
   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.warn_label = createLabel(self.form);
--   self.warn_label.left = 7;
--   self.warn_label.top = 52;
--   self.warn_label.width = 70;
--   self.warn_label.height = 50;
--   self.warn_label.Caption = "Only Advance,\n\nAdd Class Jp,\n\nAdd Abilites\n\nor Max Class \n\nJobs\n\nwhen in \n\nMenu Screen"
--

This is the specific point of the thread. The following two functions operate differently on two machines. The buttons are created, but when values are entered and the button selected, I don't get a print statement on either edit/button combination, as both goldvalue and expvalue are nil. Why does this work on another lap?
Code:

   self.set_gold = createButton(self.form);
   self.set_gold.Caption = 'Enter Gold';
   self.set_gold.height = 35;
   self.set_gold.left = 105;
   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 = 105;
   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 " .. expvalue);
                                 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
                              --print(row_1)
                              local row_2 = strings_getString(row_1.getSubItems(),0) + 0; -- Exp
                              print(row_2)
                              if (char and row_1 and row_2) then
                                 local address_1 = addresslist_getMemoryRecordByDescription(getAddressList(), char .. '-Exp');
                                 --print(address_1)
--                                 local address_2 = addresslist_getMemoryRecordByDescription(getAddressList(), char .. ' Exp 16^6');
                                 print(memoryrecord_getValue(address_1));
                                 if (address_1) then
                                    memoryrecord_setValue(address_1, row_2)-- - math.floor(row_2/65536) * 65536)
                                    print(memoryrecord_getValue(address_1));
                                    --memoryrecord_setValue(address_2, math.floor(row_2/65536))
                                 end
                              end
                              trainer.characters_rg.setItemIndex(8);
                           end--function (sender)

--   for character,_ in pairs(self.Data.Characters) do  Thee need CHaracter Data Table
--      if tonumber(character) then
--         self.characters_rg.getItems().add(_);
--
  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 hero name is ", heroname);
                                       self.listview.clear();
                                       for _,__table in pairs(self.Data.Characters.Stats[i]) do
                                          local entry = self.listview.getItems().add();
                                          entry.Caption = __table[1];
                                          local subentry = entry.getSubItems().add(__table[2]);
                                       end--                                       self.listview.clear();
--                                       for _,__table in pairs(self.Data.Stats[i]) do
--                                          local entry = self.listview.getItems().add();
--                                          entry.Caption = __table[1];
--                                          local subentry = entry.getSubItems().add(__table[2]);
                                       if heroname == "No One" then  --for _,__table in pairs(self.Data.Stats[i]) do
                                         heroname = nil;
                                       else
                                         --print("The hero name is ", heroname);
                                       end;
                                    end;--if i then
                                    if expvalue and goldvalue and heroname then
                                       RecalculateAddresses();
                                    end;--if expvalue and goldvalue and heroname then
                                    --self.characters_rg.setItemIndex(-1)
                                  end;--function (sender)
--
   self.t = createTimer(nil, false)
   self.t.onTimer = MaxHP
   self.t.Interval = 1000; --checks every 1000 milliseconds
--
   self.gm_cb = createCheckBox(self.form);
   self.gm_cb.Caption = 'God Mode';
   self.gm_cb.Height = 5;
   self.gm_cb.Left = 270;
   self.gm_cb.Width = 90;
   self.gm_cb.Top = 5;
   self.gm_cb.onClick =   function (sender)
                           if sender.Checked then
                              self.t.Enabled = true;
                              print("God mode is enabled")
                           else
                              self.t.Enabled = false;
                              print("God mode is not enabled")
                           end
                          end

   self.form.show();
end;--function trainer:start()
--
function RecalculateAddresses(sender)
  if heroname == "Zidane" then
      goldoffset = 0x518
    elseif heroname == " Vivi" then
      goldoffset = 0x488
    elseif heroname == "Garnet" then
      goldoffset = 0x3F8
    elseif heroname == "Steiner" then
      goldoffset = 0x368
    elseif heroname == "Freya" then
      goldoffset = 0x2D8
    elseif heroname == "Quina" then
      goldoffset = 0x248
    elseif heroname == "Eiko" then
      goldoffset = 0x1B9
    elseif heroname == "Amarant" then
      goldoffset = 0x129
    else
  end
 local AL = getAddressList()
 local MS = createMemScan()
 local FL = createFoundList(MS)
   memscan_firstScan(MS,
   soExactValue, vtDword, 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 forward for Gold address is ", string.format("%x", goldAddr_dec - goldoffset))
   if readInteger(goldAddr_dec - goldoffset) == expvalue then
   --print("found the correct adddress")
     correct_goldAddr_hex = goldAddr_hex
     --print("the correct address is " .. correct_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, "FFIX-GIL FFIX-GIL FFIX-GIL FFIX-GIL"))
   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)
   goldvalue = nil;
   expvalue = nil;
   heroname = nil;
   trainer.gold_value.Caption = nil
   trainer.exp_value.Caption = nil
   --trainer.characters_rg.setItemIndex(-1)
   print("The table has been recalculated")

 end--function RecalculateAddresses(sender)
--
function MaxHP(sender)
local addresslist = getAddressList()
--print("checking HP")
maxhp1address = addresslist_getMemoryRecordByDescription(addresslist, "Zidane-Max HP Field")
maxhp1 = memoryrecord_getValue(maxhp1address)
curhp1address = addresslist_getMemoryRecordByDescription(addresslist, "Zidane-Cur HP Field")
curhp1 = memoryrecord_getValue(curhp1address)
maxmp1address = addresslist_getMemoryRecordByDescription(addresslist, "Zidane-Max MP Field")
maxmp1 = memoryrecord_getValue(maxmp1address)
curmp1address = addresslist_getMemoryRecordByDescription(addresslist, "Zidane-Cur MP Field")
curmp1 = memoryrecord_getValue(curmp1address)
  maxhp2address = addresslist_getMemoryRecordByDescription(addresslist, "Vivi-Max HP Field")
  maxhp2 = memoryrecord_getValue(maxhp2address)
  curhp2address = addresslist_getMemoryRecordByDescription(addresslist, "Vivi-Cur HP Field")
  curhp2 = memoryrecord_getValue(curhp2address)
  maxmp2address = addresslist_getMemoryRecordByDescription(addresslist, "Vivi-Max MP Field")
  maxmp2 = memoryrecord_getValue(maxmp2address)
  curmp2address = addresslist_getMemoryRecordByDescription(addresslist, "Vivi-Cur MP Field")
  curmp2 = memoryrecord_getValue(curmp2address)
maxhp3address = addresslist_getMemoryRecordByDescription(addresslist, "Garnet-Max HP Field")
maxhp3 = memoryrecord_getValue(maxhp3address)
curhp3address = addresslist_getMemoryRecordByDescription(addresslist, "Garnet-Cur HP Field")
curhp3 = memoryrecord_getValue(curhp3address)
maxmp3address = addresslist_getMemoryRecordByDescription(addresslist, "Garnet-Max MP Field")
maxmp3 = memoryrecord_getValue(maxmp3address)
curmp3address = addresslist_getMemoryRecordByDescription(addresslist, "Garnet-Cur MP Field")
curmp3 = memoryrecord_getValue(curmp3address)
  maxhp4address = addresslist_getMemoryRecordByDescription(addresslist, "Steiner-Max HP Field")
  maxhp4 = memoryrecord_getValue(maxhp4address)
  curhp4address = addresslist_getMemoryRecordByDescription(addresslist, "Steiner-Cur HP Field")
  curhp4 = memoryrecord_getValue(curhp4address)
  maxmp4address = addresslist_getMemoryRecordByDescription(addresslist, "Steiner-Max MP Field")
  maxmp4 = memoryrecord_getValue(maxmp4address)
  curmp4address = addresslist_getMemoryRecordByDescription(addresslist, "Steiner-Cur MP Field")
  curmp4 = memoryrecord_getValue(curmp4address)
maxhp5address = addresslist_getMemoryRecordByDescription(addresslist, "Freya-Max HP Field")
maxhp5 = memoryrecord_getValue(maxhp5address)
curhp5address = addresslist_getMemoryRecordByDescription(addresslist, "Freya-Cur HP Field")
curhp5 = memoryrecord_getValue(curhp5address)
maxmp5address = addresslist_getMemoryRecordByDescription(addresslist, "Freya-Max MP Field")
maxmp5 = memoryrecord_getValue(maxmp5address)
curmp5address = addresslist_getMemoryRecordByDescription(addresslist, "Freya-Cur MP Field")
curmp5 = memoryrecord_getValue(curmp5address)
  maxhp6address = addresslist_getMemoryRecordByDescription(addresslist, "Quina-Max HP Field")
  maxhp6 = memoryrecord_getValue(maxhp6address)
  curhp6address = addresslist_getMemoryRecordByDescription(addresslist, "Quina-Cur HP Field")
  curhp6 = memoryrecord_getValue(curhp6address)
  maxmp6address = addresslist_getMemoryRecordByDescription(addresslist, "Quina-Max MP Field")
  maxmp6 = memoryrecord_getValue(maxmp6address)
  curmp6address = addresslist_getMemoryRecordByDescription(addresslist, "Quina-Cur MP Field")
  curmp6 = memoryrecord_getValue(curmp6address)
--maxhp7address = addresslist_getMemoryRecordByDescription(addresslist, "Shamino Max Ht Pts")
--maxhp7 = memoryrecord_getValue(maxhp7address)
--curhp7address = addresslist_getMemoryRecordByDescription(addresslist, "Shamino Cur Ht Pts")
--curhp7 = memoryrecord_getValue(curhp7address)
--maxmp7address = addresslist_getMemoryRecordByDescription(addresslist, "Shamino Max MP")
--maxmp7 = memoryrecord_getValue(maxmp7address)
--curmp7address = addresslist_getMemoryRecordByDescription(addresslist, "Shamino Cur MP")
--curmp7 = memoryrecord_getValue(curmp7address)
  --maxhp8address = addresslist_getMemoryRecordByDescription(addresslist, "Katrina Max Ht Pts")
  --maxhp8 = memoryrecord_getValue(maxhp8address)
  --curhp8address = addresslist_getMemoryRecordByDescription(addresslist, "Katrina Cur Ht Pts")
  --curhp8 = memoryrecord_getValue(curhp8address)
  --maxmp8address = addresslist_getMemoryRecordByDescription(addresslist, "Katrina Max MP")
  --maxmp8 = memoryrecord_getValue(maxmp8address)
  --curmp8address = addresslist_getMemoryRecordByDescription(addresslist, "Katrina Cur MP")
  --curmp8 = memoryrecord_getValue(curmp8address)
--mariahstatusaddress = addresslist_getMemoryRecordByDescription(addresslist, "Mariah Status")
--iolostatusaddress = addresslist_getMemoryRecordByDescription(addresslist, "Iolo Status")
--geoffstatusaddress = addresslist_getMemoryRecordByDescription(addresslist, "Geoff Status")
--jaanastatusaddress = addresslist_getMemoryRecordByDescription(addresslist, "Jaana Status")
--juliusstatusaddress = addresslist_getMemoryRecordByDescription(addresslist, "Julius Status")
--duprestatusaddress = addresslist_getMemoryRecordByDescription(addresslist, "Dupre Status")
--shaminostatusaddress = addresslist_getMemoryRecordByDescription(addresslist, "Shamino Status")
--katrinastatusaddress = addresslist_getMemoryRecordByDescription(addresslist, "Katrina Status")

--memoryrecord_setValue(mariahstatusaddress, 0)
--memoryrecord_setValue(iolostatusaddress, 0)
--memoryrecord_setValue(geoffstatusaddress, 0)
--memoryrecord_setValue(jaanastatusaddress, 0)
--memoryrecord_setValue(juliusstatusaddress, 0)
--memoryrecord_setValue(duprestatusaddress, 0)
--memoryrecord_setValue(shaminostatusaddress, 0)
--memoryrecord_setValue(katrinastatusaddress, 0)
--
    if curhp1 ~= maxhp1 then
    memoryrecord_setValue(curhp1address, maxhp1)
  end
    if curmp1 ~= maxmp1 then
      memoryrecord_setValue(curmp1address, maxmp1)
    end
  if curhp2 ~= maxhp2 then
    memoryrecord_setValue(curhp2address, maxhp2)
  end
    if curmp2 ~= maxmp2 then
      memoryrecord_setValue(curmp2address, maxmp2)
    end
  if curhp3 ~= maxhp3 then
    memoryrecord_setValue(curhp3address, maxhp3)
  end
    if curmp3 ~= maxmp3 then
      memoryrecord_setValue(curmp3address, maxmp3)
    end
  if curhp4 ~= maxhp4 then
    memoryrecord_setValue(curhp4address, maxhp4)
  end
    if curmp4 ~= maxmp4 then
      memoryrecord_setValue(curmp4address, maxmp4)
    end
--  if curhp5 ~= maxhp5 then
--    memoryrecord_setValue(curhp5address, maxhp5)
--  end
--    if curmp5 ~= maxmp5 then
--      memoryrecord_setValue(curmp5address, maxmp5)
--    end
--  if curhp6 ~= maxhp6 then
--    memoryrecord_setValue(curhp6address, maxhp6)
--  end
--    if curmp6 ~= maxmp6 then
--      memoryrecord_setValue(curmp6address, maxmp6)
--    end
--  if curhp7 ~= maxhp7 then
--    memoryrecord_setValue(curhp7address, maxhp7)
--  end
--    if curmp7 ~= maxmp7 then
--      memoryrecord_setValue(curmp7address, maxmp7)
--    end
--  if curhp8 ~= maxhp8 then
--    memoryrecord_setValue(curhp8address, maxhp8)
--  end
--    if curmp8 ~= maxmp8 then
--      memoryrecord_setValue(curmp8address, maxmp8)
--    end
end--function MaxHP

--
trainer:start();

print("help")
Back to top
View user's profile Send private message Yahoo Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Tue Mar 08, 2016 9:27 am    Post subject: Reply with quote

This is the specific point of the thread. The following two functions operate differently on two machines. The buttons are created, but when values are entered and the button selected, I don't get a print statement on either edit/button combination, as both goldvalue and expvalue are nil. Why does this work on another lap? I edited the code to reduce to the pertinent question.
Code:
trainer =    {
   --
   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 = 105;
   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 = 105;
   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 " .. expvalue);
                                 if expvalue and goldvalue and heroname then
                                    RecalculateAddresses()
                                 end
                              end--if value then
                                --self.exp_value.Caption = nil
                              end--function (sender)

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

trainer:start();

print("help")

Again, the Buttons, Edit boxes all are created, but neither of the functions work on the current pal. They do work on another machine.
Back to top
View user's profile Send private message Yahoo Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Wed Mar 09, 2016 10:59 am    Post subject: Reply with quote

88 views and not one suggestion?
DB I know you look at these threads, no thoughts from your insight?
The ver. is 6.4 if that makes any difference in syntax.
Back to top
View user's profile Send private message Yahoo Messenger
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Wed Mar 09, 2016 12:17 pm    Post subject: Reply with quote

Do you have CE6.5 from 10 Jan 2016 ?
(CE6.5 released 31 Dec 2015 has some Lua backward compatibility issues)

Redownload, reinstall, then try it again on your both machines.

_________________
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Wed Mar 09, 2016 1:25 pm    Post subject: Reply with quote

The Ver. is 6.4, is there backward compatibility issues with 6.4?

I will attempt to d/l 6.5 although I'm not sure of which ver. it is
All the setup indicates 6.5 only

Just finished he install, and sadly the same behavior exists with this version.
Question for you open the code with yours and see if it works.

You don't need the game to test the gold and exp values.
Back to top
View user's profile Send private message Yahoo Messenger
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Thu Mar 10, 2016 9:59 am    Post subject: Reply with quote

Edit control doesn't have Caption property.
Use Text

_________________
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Thu Mar 10, 2016 10:57 am    Post subject: Reply with quote

That was a copy from 6.3, where caption worked. I have changed it to text in both machines and happily it works in BOTH.
Thanks
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