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 


Naming convention
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1535

PostPosted: Wed Mar 02, 2022 2:56 pm    Post subject: Reply with quote

You are taking the String as an "index" and trying to add "+1" to it.
I added the real index to the code below and shortened the unnecessary tests.
Now the correct value is here: "i = sender.ItemIndex"

Code:
   self.profession_rg = createRadioGroup(self.form);
   self.profession_rg.height = 300;
   self.profession_rg.width = 85;
   self.profession_rg.top = 90;
   self.profession_rg.left = 110;
   for profession,_ in pairs(self.Data.Profession) do
      if tonumber(profession) then
         self.profession_rg.getItems().add(_);
      end
   end
   self.profession_rg.onClick =    function (sender)
                                    index = strings_getString(sender.getItems(), sender.ItemIndex); --heroprof
                                    i = "";
                                    i = sender.ItemIndex --self.Data.Profession[index]+ 1; -- If the character does not hold the value,, i remains nil.
                                    print(i)
                                    if i~=0 then
                                     --for k,v in pairs (self.Data.Stats) do
                                       -- if k==index then
                                       --    i = v+1 -- We placed a value from 0 to 7 into the Characters name in the table.. but our stats is placed from 1 to 8 (alternative we could force the index in the table);
                                        --end
                                     --end
                                     --if i then
                                       heroprof = index--;index = heroprof;--heroname = index;
                                       print("The index selected is", self.Data.Stats[index]);
                                       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]);
                                       end
                                       --self.listview.visible=true
                                     --end
                                     else
                                     self.listview.clear();
                                     print(i .. " None")
                                    end
                                 end

You can test it on this code.

Code:
print("start")
trainer =    {
            Data =    {
                        Characters =    {
                                          [0] = "No One";
                                          [1] = "1st";
                                          [2] = "2nd";
                                          [3] = "3rd";
                                          [4] = "4th";
                                          [5] = "5th";
                                          [6] = "6th";

                                          ["No One"] = 0; -- Index of radiogroup
                                          ["1st"] = 1;
                                          ["2nd"] = 2;
                                          ["3rd"] = 3;
                                          ["4th"] = 4;
                                          ["5th"] = 5;
                                          ["6th"] = 6;
                                       };--Characters
                        Stats =   { -- Exp and level
                                           {{1,999};{2,1999};{3,3999};{4,7999};{5,15999};{6,31999};{7,63999};{8,127999};{9,255999};{10,511999};{11,767999};{12,1167999};{13,1567999};{14,1967999};{15,2367999};{16,2967999};{17,3567999};{18,4167999};{19,4767999};{20,5367999};{21,5967999};{22,6567999};{23,7167999};{24,7767999};{25,8367999};{26,8967999};{27,9567999};{28,10167999};{29,10767999};{30,11367999};{31,11967999};{32,12567999};{33,13167999};{34,13767999};{35,14367999};{36,14967999};{37,15567999};{38,16167999};{39,16767999};{40,17367999};{41,17967999};{42,18567999};{43,19167999};{44,19767999};{45,20367999};{46,20967999};{47,21567999};{48,22167999};{49,22767999};{50,23367999};{51,23967999};{52,24567999};{53,25167999};{54,25767999};{55,26367999};{56,26967999};{57,27567999};{58,28167999};{59,28767999};{60,29367999};{61,29967999};{62,30567999};{63,31167999};{64,31767999};{65,32367999};{66,32967999};{67,33567999};{68,34167999};{69,34767999};{70,35367999};{71,35967999};{72,36567999};{73,37167999};{74,37767999};{75,38367999};{76,38967999};{77,39567999};{78,40167999};{79,40767999};{80,41367999};{81,41967999};{82,42567999};{83,43167999};{84,43767999};{85,44367999};{86,44967999};{87,45567999};{88,46167999};{89,46767999};{90,47367999};{91,47967999};{92,48567999};{93,49167999};{94,49767999};{95,50367999};{96,50967999};{97,51567999};{98,52167999};{99,52767999};{100,53367999};{101,53967999};{102,54567999};{103,55167999};{104,55767999};{105,56367999};{106,56967999};{107,57567999};{108,58167999};{109,58767999};{110,59367999};};
                                           {{1,1249};{2,2499};{3,4999};{4,9999};{5,19999};{6,39999};{7,79999};{8,159999};{9,319999};{10,639999};{11,1014999};{12,1414999};{13,1814999};{14,2214999};{15,2614999};{16,3214999};{17,3814999};{18,4414999};{19,5014999};{20,5614999};{21,6214999};{22,6814999};{23,7414999};{24,8014999};{25,8614999};{26,9214999};{27,9814999};{28,10414999};{29,11044999};{30,11614999};{31,12214999};{32,12814999};{33,13414999};{34,14014999};{35,14614999};{36,15214999};{37,15814999};{38,16414999};{39,17014999};{40,17614999};{41,18214999};{42,18814999};{43,19414999};{44,20014999};{45,20614999};{46,21214999};{47,21814999};{48,22414999};{49,23014999};{50,23614999};{51,24214999};{52,24814999};{53,25414999};{54,26014999};{55,26614999};{56,27214999};{57,27814999};{58,28414999};{59,29014999};{60,29614999};{61,30214999};{62,30814999};{63,31414999};{64,32014999};{65,32614999};{66,33214999};{67,33814999};{68,34414999};{69,35014999};{70,35614999};{71,36214999};{72,36814999};{73,37414999};{74,38014999};{75,38614999};{76,39214999};{77,39814999};{78,40414999};{79,41014999};{80,41614999};{81,42214999};{82,42814999};{83,43414999};{84,44014999};{85,44614999};{86,45214999};{87,45814999};{88,46414999};{89,47014999};{90,47614999};{91,48214999};{92,48814999};{93,49414999};{94,50014999};{95,50614999};{96,51214999};{97,51814999};{98,52414999};{99,53014999};{100,53614999};{101,54214999};{102,54814999};{103,55414999};{104,56014999};{105,56614999};{106,57214999};{107,57814999};{108,58414999};{109,59014999};{110,59614999};};
                                           {{1,1099};{2,2199};{3,4399};{4,8799};{5,17599};{6,35199};{7,70399};{8,140799};{9,281599};{10,563199};{11,875199};{12,1275199};{13,1675199};{14,2075199};{15,2475199};{16,3075199};{17,3675199};{18,4275199};{19,4875199};{20,5475199};{21,6075199};{22,6675199};{23,7275199};{24,7875199};{25,8475199};{26,9075199};{27,9675199};{28,10275199};{29,10875199};{30,11475199};{31,12075199};{32,12675199};{33,13275199};{34,13875199};{35,14475199};{36,15075199};{37,15675199};{38,16275199};{39,16875199};{40,17475199};{41,18075199};{42,18675199};{43,19275199};{44,19875199};{45,20475199};{46,21075199};{47,21675199};{48,22275199};{49,22875199};{50,23475199};{51,24075199};{52,24675199};{53,25275199};{54,25875199};{55,26475199};{56,27075199};{57,27675199};{58,28275199};{59,28875199};{60,29475199};{61,30075199};{62,30675199};{63,31275199};{64,31875199};{65,32475199};{66,33075199};{67,33675199};{68,34275199};{69,34875199};{70,35475199};{71,36075199};{72,36675199};{73,37275199};{74,37875199};{75,38475199};{76,39075199};{77,39675199};{78,40275199};{79,40875199};{80,41475199};{81,42075199};{82,42675199};{83,43275199};{84,43875199};{85,44475199};{86,45075199};{87,45675199};{88,46275199};{89,46875199};{90,47475199};{91,48075199};{92,48675199};{93,49275199};{94,49875199};{95,50475199};{96,51075199};{97,51675199};{98,52275199};{99,52875199};{100,53475199};{101,54075199};{102,54675199};{103,55275199};{104,55875199};{105,56475199};{106,57075199};{107,57675199};{108,58275199};{109,58875199};{110,59475199};};
                                           {{1,899};{2,1799};{3,3599};{4,7199};{5,14399};{6,28799};{7,57599};{8,115199};{9,230399};{10,460799};{11,685799};{12,1085799};{13,1485799};{14,1885799};{15,2285799};{16,2885799};{17,3485799};{18,4085799};{19,4685799};{20,5285799};{21,5885799};{22,6485799};{23,7085799};{24,7685799};{25,8285799};{26,8885799};{27,9485799};{28,10085799};{29,10685799};{30,11285799};{31,11885799};{32,12485799};{33,13085799};{34,13685799};{35,14285799};{36,14885799};{37,15485799};{38,16085799};{39,16685799};{40,17285799};{41,17885799};{42,18485799};{43,19085799};{44,19685799};{45,20285799};{46,20885799};{47,21485799};{48,22085799};{49,22685799};{50,23285799};{51,23885799};{52,24485799};{53,25085799};{54,25685799};{55,26285799};{56,26885799};{57,27485799};{58,28085799};{59,28685799};{60,29285799};{61,29885799};{62,30485799};{63,31085799};{64,31685799};{65,32285799};{66,32885799};{67,33485799};{68,34085799};{69,34685799};{70,35285799};{71,35885799};{72,36485799};{73,37085799};{74,37685799};{75,38285799};{76,38885799};{77,39485799};{78,40085799};{79,40685799};{80,41285799};{81,41885799};{82,42485799};{83,43085799};{84,43685799};{85,44285799};{86,44885799};{87,45485799};{88,46085799};{89,46685799};{90,47285799};{91,47885799};{92,48485799};{93,49085799};{94,49685799};{95,50285799};{96,50885799};{97,51485799};{98,52085799};{99,52685799};{100,53285799};{101,53885799};{102,54485799};{103,55085799};{104,55685799};{105,56285799};{106,56885799};{107,57485799};{108,58085799};{109,58685799};{110,59285799};};
                                           {{1,1299};{2,2599};{3,5199};{4,10399};{5,20799};{6,41599};{7,83199};{8,166399};{9,332799};{10,665599};{11,1065599};{12,1465599};{13,1865599};{14,2265599};{15,2665599};{16,3265599};{17,3865599};{18,4465599};{19,5065599};{20,5665599};{21,6265599};{22,6865599};{23,7465599};{24,8065599};{25,8665599};{26,9265599};{27,9865599};{28,10465599};{29,11065599};{30,11665599};{31,12265599};{32,12865599};{33,13465599};{34,14065599};{35,14665599};{36,15265599};{37,15865599};{38,16465599};{39,17065599};{40,17665599};{41,18265599};{42,18865599};{43,19465599};{44,20065599};{45,20665599};{46,21265599};{47,21865599};{48,22465599};{49,23065599};{50,23665599};{51,24265599};{52,24865599};{53,25465599};{54,26065599};{55,26665599};{56,27265599};{57,27865599};{58,28465599};{59,29065599};{60,29665599};{61,30265599};{62,30865599};{63,31465599};{64,32065599};{65,32665599};{66,33265599};{67,33865599};{68,34465599};{69,35065599};{70,35665599};{71,36265599};{72,36865599};{73,37465599};{74,38065599};{75,38665599};{76,39265599};{77,39865599};{78,40465599};{79,41065599};{80,41665599};{81,42265599};{82,42865599};{83,43465599};{84,44065599};{85,44665599};{86,45265599};{87,45865599};{88,46465599};{89,47065599};{90,47665599};{91,48265599};{92,48865599};{93,49465599};{94,50065599};{95,50665599};{96,51265599};{97,51865599};{98,52465599};{99,53065599};{100,53665599};{101,54265599};{102,54865599};{103,55465599};{104,56065599};{105,56665599};{106,57265599};{107,57865599};{108,58465599};{109,59065599};{110,59665599};};
                                           {{1,1149};{2,2299};{3,4599};{4,9199};{5,18399};{6,36799};{7,73599};{8,147199};{9,294399};{10,588799};{11,913799};{12,1313799};{13,1713799};{14,2113799};{15,2513799};{16,3113799};{17,3713799};{18,4313799};{19,4913799};{20,5513799};{21,6113799};{22,6713799};{23,7313799};{24,7913799};{25,8513799};{26,9113799};{27,9713799};{28,10313799};{29,10913799};{30,11513799};{31,12113799};{32,12713799};{33,13313799};{34,13913799};{35,14513799};{36,15113799};{37,15713799};{38,16313799};{39,16913799};{40,17513799};{41,18113799};{42,18713799};{43,19313799};{44,19913799};{45,20513799};{46,21113799};{47,21713799};{48,22313799};{49,22913799};{50,23513799};{51,24113799};{52,24713799};{53,25313799};{54,25913799};{55,26513799};{56,27113799};{57,27713799};{58,28313799};{59,28913799};{60,29513799};{61,30113799};{62,30713799};{63,31313799};{64,31913799};{65,32513799};{66,33113799};{67,33713799};{68,34313799};{69,34913799};{70,35513799};{71,36113799};{72,36713799};{73,37313799};{74,37913799};{75,38513799};{76,39113799};{77,39713799};{78,40313799};{79,40913799};{80,41513799};{81,42113799};{82,42713799};{83,43313799};{84,43913799};{85,44513799};{86,45113799};{87,45713799};{88,46313799};{89,46913799};{90,47513799};{91,48113799};{92,48713799};{93,49313799};{94,49913799};{95,50513799};{96,51113799};{97,51713799};{98,52313799};{99,52913799};{100,53513799};{101,54113799};{102,54713799};{103,55313799};{104,55913799};{105,56513799};{106,57113799};{107,57713799};{108,58313799};{109,58913799};{110,59513799};};
                                           {{1,1249};{2,2499};{3,4999};{4,9999};{5,19999};{6,39999};{7,79999};{8,159999};{9,319999};{10,639999};{11,1014999};{12,1414999};{13,1814999};{14,2214999};{15,2614999};{16,3214999};{17,3814999};{18,4414999};{19,5014999};{20,5614999};{21,6214999};{22,6814999};{23,7414999};{24,8014999};{25,8614999};{26,9214999};{27,9814999};{28,10414999};{29,11044999};{30,11614999};{31,12214999};{32,12814999};{33,13414999};{34,14014999};{35,14614999};{36,15214999};{37,15814999};{38,16414999};{39,17014999};{40,17614999};{41,18214999};{42,18814999};{43,19414999};{44,20014999};{45,20614999};{46,21214999};{47,21814999};{48,22414999};{49,23014999};{50,23614999};{51,24214999};{52,24814999};{53,25414999};{54,26014999};{55,26614999};{56,27214999};{57,27814999};{58,28414999};{59,29014999};{60,29614999};{61,30214999};{62,30814999};{63,31414999};{64,32014999};{65,32614999};{66,33214999};{67,33814999};{68,34414999};{69,35014999};{70,35614999};{71,36214999};{72,36814999};{73,37414999};{74,38014999};{75,38614999};{76,39214999};{77,39814999};{78,40414999};{79,41014999};{80,41614999};{81,42214999};{82,42814999};{83,43414999};{84,44014999};{85,44614999};{86,45214999};{87,45814999};{88,46414999};{89,47014999};{90,47614999};{91,48214999};{92,48814999};{93,49414999};{94,50014999};{95,50614999};{96,51214999};{97,51814999};{98,52414999};{99,53014999};{100,53614999};{101,54214999};{102,54814999};{103,55414999};{104,56014999};{105,56614999};{106,57214999};{107,57814999};{108,58414999};{109,59014999};{110,59614999};};
                                           {{1,1249};{2,2499};{3,4999};{4,9999};{5,19999};{6,39999};{7,79999};{8,159999};{9,319999};{10,639999};{11,1014999};{12,1414999};{13,1814999};{14,2214999};{15,2614999};{16,3214999};{17,3814999};{18,4414999};{19,5014999};{20,5614999};{21,6214999};{22,6814999};{23,7414999};{24,8014999};{25,8614999};{26,9214999};{27,9814999};{28,10414999};{29,11044999};{30,11614999};{31,12214999};{32,12814999};{33,13414999};{34,14014999};{35,14614999};{36,15214999};{37,15814999};{38,16414999};{39,17014999};{40,17614999};{41,18214999};{42,18814999};{43,19414999};{44,20014999};{45,20614999};{46,21214999};{47,21814999};{48,22414999};{49,23014999};{50,23614999};{51,24214999};{52,24814999};{53,25414999};{54,26014999};{55,26614999};{56,27214999};{57,27814999};{58,28414999};{59,29014999};{60,29614999};{61,30214999};{62,30814999};{63,31414999};{64,32014999};{65,32614999};{66,33214999};{67,33814999};{68,34414999};{69,35014999};{70,35614999};{71,36214999};{72,36814999};{73,37414999};{74,38014999};{75,38614999};{76,39214999};{77,39814999};{78,40414999};{79,41014999};{80,41614999};{81,42214999};{82,42814999};{83,43414999};{84,44014999};{85,44614999};{86,45214999};{87,45814999};{88,46414999};{89,47014999};{90,47614999};{91,48214999};{92,48814999};{93,49414999};{94,50014999};{95,50614999};{96,51214999};{97,51814999};{98,52414999};{99,53014999};{100,53614999};{101,54214999};{102,54814999};{103,55414999};{104,56014999};{105,56614999};{106,57214999};{107,57814999};{108,58414999};{109,59014999};{110,59614999};};
                                           {{1,1149};{2,2299};{3,4599};{4,9199};{5,18399};{6,36799};{7,73599};{8,147199};{9,294399};{10,588799};{11,913799};{12,1313799};{13,1713799};{14,2113799};{15,2513799};{16,3113799};{17,3713799};{18,4313799};{19,4913799};{20,5513799};{21,6113799};{22,6713799};{23,7313799};{24,7913799};{25,8513799};{26,9113799};{27,9713799};{28,10313799};{29,10913799};{30,11513799};{31,12113799};{32,12713799};{33,13313799};{34,13913799};{35,14513799};{36,15113799};{37,15713799};{38,16313799};{39,16913799};{40,17513799};{41,18113799};{42,18713799};{43,19313799};{44,19913799};{45,20513799};{46,21113799};{47,21713799};{48,22313799};{49,22913799};{50,23513799};{51,24113799};{52,24713799};{53,25313799};{54,25913799};{55,26513799};{56,27113799};{57,27713799};{58,28313799};{59,28913799};{60,29513799};{61,30113799};{62,30713799};{63,31313799};{64,31913799};{65,32513799};{66,33113799};{67,33713799};{68,34313799};{69,34913799};{70,35513799};{71,36113799};{72,36713799};{73,37313799};{74,37913799};{75,38513799};{76,39113799};{77,39713799};{78,40313799};{79,40913799};{80,41513799};{81,42113799};{82,42713799};{83,43313799};{84,43913799};{85,44513799};{86,45113799};{87,45713799};{88,46313799};{89,46913799};{90,47513799};{91,48113799};{92,48713799};{93,49313799};{94,49913799};{95,50513799};{96,51113799};{97,51713799};{98,52313799};{99,52913799};{100,53513799};{101,54113799};{102,54713799};{103,55313799};{104,55913799};{105,56513799};{106,57113799};{107,57713799};{108,58313799};{109,58913799};{110,59513799};};
                                           {{1,1499};{2,2999};{3,5999};{4,11999};{5,23999};{6,47999};{7,95999};{8,191999};{9,383999};{10,767999};{11,1212999};{12,1612999};{13,2012999};{14,2412999};{15,2812999};{16,3412999};{17,4012999};{18,4612999};{19,5212999};{20,5812999};{21,6412999};{22,7012999};{23,7612999};{24,8212999};{25,8812999};{26,9412999};{27,10012999};{28,10612999};{29,11212999};{30,11812999};{31,12412999};{32,13012999};{33,13612999};{34,14212999};{35,14812999};{36,15412999};{37,16012999};{38,16612999};{39,17212999};{40,17812999};{41,18412999};{42,19012999};{43,19612999};{44,20212999};{45,20812999};{46,21412999};{47,22012999};{48,22612999};{49,23212999};{50,23812999};{51,24412999};{52,25012999};{53,25612999};{54,26212999};{55,26812999};{56,27412999};{57,28012999};{58,28612999};{59,29212999};{60,29812999};{61,30412999};{62,31012999};{63,31612999};{64,32212999};{65,32812999};{66,33412999};{67,34012999};{68,34612999};{69,35212999};{70,35812999};{71,36412999};{72,37012999};{73,37612999};{74,38212999};{75,38812999};{76,39412999};{77,40012999};{78,40612999};{79,41212999};{80,41812999};{81,42412999};{82,43012999};{83,43612999};{84,44212999};{85,44812999};{86,45412999};{87,46012999};{88,46612999};{89,47212999};{90,47812999};{91,48412999};{92,49012999};{93,49612999};{94,50212999};{95,50812999};{96,51412999};{97,52012999};{98,52612999};{99,53212999};{100,53812999};{101,54412999};{102,55012999};{103,55612999};{104,56212999};{105,56812999};{106,57412999};{107,58012999};{108,58612999};{109,59212999};{110,59812999};};
                                           {{1,1299};{2,2599};{3,5199};{4,10399};{5,20799};{6,41599};{7,83199};{8,166399};{9,332799};{10,665599};{11,1065599};{12,1465599};{13,1865599};{14,2265599};{15,2665599};{16,3265599};{17,3865599};{18,4465599};{19,5065599};{20,5665599};{21,6265599};{22,6865599};{23,7465599};{24,8065599};{25,8665599};{26,9265599};{27,9865599};{28,10465599};{29,11065599};{30,11665599};{31,12265599};{32,12865599};{33,13465599};{34,14065599};{35,14665599};{36,15265599};{37,15865599};{38,16465599};{39,17065599};{40,17665599};{41,18265599};{42,18865599};{43,19465599};{44,20065599};{45,20665599};{46,21265599};{47,21865599};{48,22465599};{49,23065599};{50,23665599};{51,24265599};{52,24865599};{53,25465599};{54,26065599};{55,26665599};{56,27265599};{57,27865599};{58,28465599};{59,29065599};{60,29665599};{61,30265599};{62,30865599};{63,31465599};{64,32065599};{65,32665599};{66,33265599};{67,33865599};{68,34465599};{69,35065599};{70,35665599};{71,36265599};{72,36865599};{73,37465599};{74,38065599};{75,38665599};{76,39265599};{77,39865599};{78,40465599};{79,41065599};{80,41665599};{81,42265599};{82,42865599};{83,43465599};{84,44065599};{85,44665599};{86,45265599};{87,45865599};{88,46465599};{89,47065599};{90,47665599};{91,48265599};{92,48865599};{93,49465599};{94,50065599};{95,50665599};{96,51265599};{97,51865599};{98,52465599};{99,53065599};{100,53665599};{101,54265599};{102,54865599};{103,55465599};{104,56065599};{105,56665599};{106,57265599};{107,57865599};{108,58465599};{109,59065599};{110,59665599};};
                                           {{1,1399};{2,2799};{3,5599};{4,11199};{5,22399};{6,44799};{7,89599};{8,179199};{9,358399};{10,716799};{11,1131799};{12,1531799};{13,1931799};{14,2331799};{15,2731799};{16,3331799};{17,3931799};{18,4531799};{19,5131799};{20,5731799};{21,6331799};{22,6931799};{23,7531799};{24,8131799};{25,8731799};{26,9331799};{27,9931799};{28,10531799};{29,11131799};{30,11731799};{31,12331799};{32,12931799};{33,13531799};{34,14131799};{35,14731799};{36,15331799};{37,15931799};{38,16531799};{39,17131799};{40,17731799};{41,18331799};{42,18931799};{43,19531799};{44,20131799};{45,20731799};{46,21331799};{47,21931799};{48,22531799};{49,23131799};{50,23731799};{51,24331799};{52,24931799};{53,25531799};{54,26131799};{55,26731799};{56,27331799};{57,27931799};{58,28531799};{59,29131799};{60,29731799};{61,30331799};{62,30931799};{63,31531799};{64,32131799};{65,32731799};{66,33331799};{67,33931799};{68,34531799};{69,35131799};{70,35731799};{71,36331799};{72,36931799};{73,37531799};{74,38131799};{75,38731799};{76,39331799};{77,39931799};{78,40531799};{79,41131799};{80,41731799};{81,42331799};{82,42931799};{83,43531799};{84,44131799};{85,44731799};{86,45331799};{87,45931799};{88,46531799};{89,47131799};{90,47731799};{91,48331799};{92,48931799};{93,49531799};{94,50131799};{95,50731799};{96,51331799};{97,51931799};{98,52531799};{99,53131799};{100,53731799};{101,54331799};{102,54931799};{103,55531799};{104,56131799};{105,56731799};{106,57331799};{107,57931799};{108,58531799};{109,59131799};{110,59731799};};
                                           {{1,1399};{2,2799};{3,5599};{4,11199};{5,22399};{6,44799};{7,89599};{8,179199};{9,358399};{10,716799};{11,1131799};{12,1531799};{13,1931799};{14,2331799};{15,2731799};{16,3331799};{17,3931799};{18,4531799};{19,5131799};{20,5731799};{21,6331799};{22,6931799};{23,7531799};{24,8131799};{25,8731799};{26,9331799};{27,9931799};{28,10531799};{29,11131799};{30,11731799};{31,12331799};{32,12931799};{33,13531799};{34,14131799};{35,14731799};{36,15331799};{37,15931799};{38,16531799};{39,17131799};{40,17731799};{41,18331799};{42,18931799};{43,19531799};{44,20131799};{45,20731799};{46,21331799};{47,21931799};{48,22531799};{49,23131799};{50,23731799};{51,24331799};{52,24931799};{53,25531799};{54,26131799};{55,26731799};{56,27331799};{57,27931799};{58,28531799};{59,29131799};{60,29731799};{61,30331799};{62,30931799};{63,31531799};{64,32131799};{65,32731799};{66,33331799};{67,33931799};{68,34531799};{69,35131799};{70,35731799};{71,36331799};{72,36931799};{73,37531799};{74,38131799};{75,38731799};{76,39331799};{77,39931799};{78,40531799};{79,41131799};{80,41731799};{81,42331799};{82,42931799};{83,43531799};{84,44131799};{85,44731799};{86,45331799};{87,45931799};{88,46531799};{89,47131799};{90,47731799};{91,48331799};{92,48931799};{93,49531799};{94,50131799};{95,50731799};{96,51331799};{97,51931799};{98,52531799};{99,53131799};{100,53731799};{101,54331799};{102,54931799};{103,55531799};{104,56131799};{105,56731799};{106,57331799};{107,57931799};{108,58531799};{109,59131799};{110,59731799};};
                                           {{1,1499};{2,2999};{3,5999};{4,11999};{5,23999};{6,47999};{7,95999};{8,191999};{9,383999};{10,767999};{11,1212999};{12,1612999};{13,2012999};{14,2412999};{15,2812999};{16,3412999};{17,4012999};{18,4612999};{19,5212999};{20,5812999};{21,6412999};{22,7012999};{23,7612999};{24,8212999};{25,8812999};{26,9412999};{27,10012999};{28,10612999};{29,11212999};{30,11812999};{31,12412999};{32,13012999};{33,13612999};{34,14212999};{35,14812999};{36,15412999};{37,16012999};{38,16612999};{39,17212999};{40,17812999};{41,18412999};{42,19012999};{43,19612999};{44,20212999};{45,20812999};{46,21412999};{47,22012999};{48,22612999};{49,23212999};{50,23812999};{51,24412999};{52,25012999};{53,25612999};{54,26212999};{55,26812999};{56,27412999};{57,28012999};{58,28612999};{59,29212999};{60,29812999};{61,30412999};{62,31012999};{63,31612999};{64,32212999};{65,32812999};{66,33412999};{67,34012999};{68,34612999};{69,35212999};{70,35812999};{71,36412999};{72,37012999};{73,37612999};{74,38212999};{75,38812999};{76,39412999};{77,40012999};{78,40612999};{79,41212999};{80,41812999};{81,42412999};{82,43012999};{83,43612999};{84,44212999};{85,44812999};{86,45412999};{87,46012999};{88,46612999};{89,47212999};{90,47812999};{91,48412999};{92,49012999};{93,49612999};{94,50212999};{95,50812999};{96,51412999};{97,52012999};{98,52612999};{99,53212999};{100,53812999};{101,54412999};{102,55012999};{103,55612999};{104,56212999};{105,56812999};{106,57412999};{107,58012999};{108,58612999};{109,59212999};{110,59812999};};
                                   };-- Stats Exp and level
                        Profession =  {
                                           [0] = "None";
                                           [1] = "Fighter";
                                           [2] = "Mage";
                                           [3] = "Priest";
                                           [4] = "Thief";
                                           [5] = "Ranger";
                                           [6] = "Alchemist";
                                           [7] = "Bard";
                                           [8] = "Psionic";
                                           [9] = "Valkyrie";
                                           [10] = "Bishop";
                                           [11] = "Lord";
                                           [12] = "Samuri";
                                           [13] = "Monk";
                                           [14] = "Ninja";
                                      };--Profession
                     };--Data
            };--Trainer
--
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 = 350;
   self.form.Height = 410;
   self.form.Left = 470;
   self.form.Top =5;
--
   self.value_panel1 = createPanel(self.form);
   self.value_panel1.Caption = '';
   self.value_panel1.left = 5;
   self.value_panel1.top = 5;
   self.value_panel1.Height = 35;
   self.value_panel1.Width = 120;
--
   self.value_panel2 = createPanel(self.form);
   self.value_panel2.Caption = '';
   self.value_panel2.left = 5;
   self.value_panel2.top = 45;
   self.value_panel2.Height = 35;
   self.value_panel2.Width = 120;
--
   self.exp_value = createEdit(self.value_panel1);
   self.exp_value.top = 3;
   self.exp_value.left = 10;
   self.exp_value.Width = 105;
   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.gold_value = createEdit(self.value_panel2);
   self.gold_value.top = 3;
   self.gold_value.left = 10;
   self.gold_value.Width = 105;
   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_exp.onClick(); end return key; end)
--
   self.Level = createLabel(self.form);
   self.Level.top = 90;
   self.Level.left = 85;
   self.Level.Width = 25;
   self.Level.Height = 20;
   self.Level.Caption = "Lvl"
--
   self.HeroOneEdit = createEdit(self.form);
   self.HeroOneEdit.top = 110;
   self.HeroOneEdit.left = 85;
   self.HeroOneEdit.Width = 20;
   self.HeroOneEdit.Height = 20;
--
   self.HeroTwoEdit = createEdit(self.form);
   self.HeroTwoEdit.top = 137;
   self.HeroTwoEdit.left = 85;
   self.HeroTwoEdit.Width = 20;
   self.HeroTwoEdit.Height = 20;
--
   self.HeroThreeEdit = createEdit(self.form);
   self.HeroThreeEdit.top = 164;
   self.HeroThreeEdit.left = 85;
   self.HeroThreeEdit.Width = 20;
   self.HeroThreeEdit.Height = 20;
--
   self.HeroFourEdit = createEdit(self.form);
   self.HeroFourEdit.top = 191;
   self.HeroFourEdit.left = 85;
   self.HeroFourEdit.Width = 20;
   self.HeroFourEdit.Height = 20;
--
   self.HeroFiveEdit = createEdit(self.form);
   self.HeroFiveEdit.top = 218;
   self.HeroFiveEdit.left = 85;
   self.HeroFiveEdit.Width = 20;
   self.HeroFiveEdit.Height = 20;
--
   self.HeroSixEdit = createEdit(self.form);
   self.HeroSixEdit.top = 245;
   self.HeroSixEdit.left = 85;
   self.HeroSixEdit.Width = 20;
   self.HeroSixEdit.Height = 20;
--
--
   self.AddExpEdit = createEdit(self.form);
   self.AddExpEdit.Top = 310
   self.AddExpEdit.Left = 5;
   self.AddExpEdit.Width = 60;
   self.AddExpEdit.Height = 20;
--
   self.set_AddExpEdit = createButton(self.form)
   self.set_AddExpEdit.Top = 335;
   self.set_AddExpEdit.Left = 5;
   self.set_AddExpEdit.Width = 60;
   self.set_AddExpEdit.Height = 25;
   self.set_AddExpEdit.Caption = "Add Exp";
   self.set_AddExpEdit.onClick = function (sender)
                                   local value = tonumber(self.AddExpEdit.Text);
                                     if value then
                                       addexp = tonumber(value);
                                       print("The experience to add is " .. addexp);
                                       local aL = getAddressList();
                                         memoryrecord_setValue(addresslist_getMemoryRecordByDescription(aL, "1st Exp G"), tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(aL, "1st Exp G"))) + addexp);
                                         memoryrecord_setValue(addresslist_getMemoryRecordByDescription(aL, "2nd Exp G"), tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(aL, "2nd Exp G"))) + addexp);
                                         memoryrecord_setValue(addresslist_getMemoryRecordByDescription(aL, "3rd Exp G"), tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(aL, "3rd Exp G"))) + addexp);
                                         memoryrecord_setValue(addresslist_getMemoryRecordByDescription(aL, "4th Exp G"), tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(aL, "4th Exp G"))) + addexp);
                                         memoryrecord_setValue(addresslist_getMemoryRecordByDescription(aL, "5th Exp G"), tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(aL, "5th Exp G"))) + addexp);
                                         memoryrecord_setValue(addresslist_getMemoryRecordByDescription(aL, "6th Exp G"), tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(aL, "6th Exp G"))) + addexp);
                                     end;--if value then
                                   end;--function (sender)
--
   self.Info = createLabel(self.form);
   self.Info.top = 5;
   self.Info.left = 240;
   self.Info.Width = 105;
   self.Info.Height = 80;
   self.Info.Caption = "Enter\nExp, Gold, and\nHero\nTo Recalcule"
--
   self.set_exp = createButton(self.form);
   self.set_exp.Caption = 'Enter Exp';
   self.set_exp.height = 35;
   self.set_exp.left = 135;
   self.set_exp.top = 5;
   self.set_exp.width = 100;
   self.set_exp.onClick =    function (sender)
                              local value = tonumber(self.exp_value.Text);
                              if value then
                                 expvalue = value;
                                 print("The experience entered " .. expvalue);
                                 if expvalue and goldvalue and heroname then
                                    RecalculateAddresses()
                                 end
                              end
                           end
--
   self.set_gold = createButton(self.form);
   self.set_gold.Caption = 'Enter Gold';
   self.set_gold.height = 35;
   self.set_gold.left = 135;
   self.set_gold.top = 45;
   self.set_gold.width = 100;
   self.set_gold.onClick =    function (sender)
                              local value = tonumber(self.gold_value.Text);
                              if value then
                                 goldvalue = value;
                                 print("The gold entered " .. goldvalue);
                                 if expvalue and goldvalue and heroname then
                                    RecalculateAddresses()
                                 end
                              end
                           end
--
--
   self.characters_rg = createRadioGroup(self.form);
   self.characters_rg.height = 205;
   self.characters_rg.width = 75;
   self.characters_rg.top = 90;
   self.characters_rg.left = 5;
   self.characters_rg.Caption = "Hero";
   for character,_ in pairs(self.Data.Characters) do
      if tonumber(character) then
         self.characters_rg.getItems().add(_);
      end
   end
   self.characters_rg.onClick =    function (sender)
                                    local AL = getAddressList()
                                    local index = strings_getString(sender.getItems(), sender.ItemIndex); -- I'm bit lazy, so sender == trainer.characters_rg
                                    local i = nil;
                                    i = self.Data.Characters[index] + 1; -- If the character does not hold the value,, i remains nil.
                                    --print(i)
                                     --for k in (self.Data.Characters) do--,v in pairs (self.Data.Characters) do
                                        --if k==index then
                                           --i = v+1 -- We placed a value from 0 to 6 into the Characters name in the table.. but our stats is placed from 1 to 8 (alternative we could force the index in the table);
                                        --end
                                     --end
                                    if i then
                                       heroname = index;
                                        if recalc then
                                          heroprof = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, heroname .. ' Profession')));--1st Profession
                                          heroexp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, heroname .. ' Exp')));--2nd Exp
                                        end
                                       --print("The index selected is", self.Data.Characters[index]);
                                       --print("The hero selected from index is ", index);
                                       print("The hero name is ", heroname);
                                       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]);
                                       end
                                    end
                                    if expvalue and goldvalue and heroname then
                                       RecalculateAddresses()
                                    end
                                 end
--
   self.profession_rg = createRadioGroup(self.form);
   self.profession_rg.height = 300;
   self.profession_rg.width = 85;
   self.profession_rg.top = 90;
   self.profession_rg.left = 110;
   for profession,_ in pairs(self.Data.Profession) do
      if tonumber(profession) then
         self.profession_rg.getItems().add(_);
      end
   end
   self.profession_rg.onClick =    function (sender)
                                    index = strings_getString(sender.getItems(), sender.ItemIndex); --heroprof
                                    i = "";
                                    i = sender.ItemIndex --self.Data.Profession[index]+ 1; -- If the character does not hold the value,, i remains nil.
                                    print(i)
                                    if i~=0 then
                                     --for k,v in pairs (self.Data.Stats) do
                                       -- if k==index then
                                       --    i = v+1 -- We placed a value from 0 to 7 into the Characters name in the table.. but our stats is placed from 1 to 8 (alternative we could force the index in the table);
                                        --end
                                     --end
                                     --if i then
                                       heroprof = index--;index = heroprof;--heroname = index;
                                       print("The index selected is", self.Data.Stats[index]);
                                       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]);
                                       end
                                       --self.listview.visible=true
                                     --end
                                     else
                                     self.listview.clear();
                                     print(i .. " None")
                                    end
                                 end
--
   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 = 90;
   self.listview.width = 110;
   self.listview.left = 225;
   self.listview.height = 300;
   --self.listview.Visible = false;
   self.listview.onClick = function (sender)
                              local char
                              if (self.profession_rg.ItemIndex >= 0 ) then
                                 char = strings_getString(self.profession_rg.getItems(), self.profession_rg.ItemIndex);
                                 print(char.." in listview")
                              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 = heroexp--addresslist_getMemoryRecordByDescription(getAddressList(), heroname .. ' Exp');
                                 if (address_1 and address_2) then
                                    memoryrecord_setValue(address_1, row_2)
                                 end
                              end
                              self.profession_rg.setItemIndex(14);
                           end
   self.listview_colum1 = self.listview.getColumns().add()
   self.listview_colum1.Width = 30;
   self.listview_colum1.Caption = 'Lvl';
   self.listview_colum2 = self.listview.getColumns().add()
   self.listview_colum2.Width = 75;
   self.listview_colum2.Caption = 'Exp';
--
   self.gm_cb = createCheckBox(self.form);
   self.gm_cb.Caption = 'God Mode';
   self.gm_cb.Height = 25;
   self.gm_cb.Left = 240;
   self.gm_cb.Width = 100;
   self.gm_cb.Top = 62;
   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();
print("God mode is not enabled");
end--trainer
--
   tde = createTimer(nil, true)
   timer_onTimer(tde, DisplayEdits)
   timer_setInterval(tde, 1000)
   timer_setEnabled(tde, false)
--
   t = createTimer(nil, true)
   timer_onTimer(t, MaxHP)
   timer_setInterval(t, 1000)--checks every 1000 milliseconds
   timer_setEnabled(t, false)
--
   tstop = createTimer(nil)
   tstop.Interval = 1000
   tstop.onTimer = function(tstop)
                      if(getOpenedProcessID() ~= 0)
                      and (readInteger("kernel32.dll") == nil) then
                         closeCE()
                      end
                   end
   tstop.Enabled = true
--
function RecalculateAddresses()

end --function trainer:start()

trainer:start()

_________________
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
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Wed Mar 02, 2022 9:13 pm    Post subject: Reply with quote

I would never presume to question you. I just assume you are correct.
I pasted the code and it does work with a couple of errors that I painfully fixed, then brought back some previous commented out features and now I have an undisclosed LUA error. After about 4 hours' worth of inserting print statements, I narrowed it down to two statements. These are after the recalculation function has been complete. I wanted to set all of the objects used in the function to normal unused state.
Code:

trainer.characters_rg.ItemIndex = 0;


What is the correct syntax for setting the rg to 0?
Back to top
View user's profile Send private message Yahoo Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1535

PostPosted: Thu Mar 03, 2022 3:22 am    Post subject: Reply with quote

bknight2602 wrote:

Code:

trainer.characters_rg.ItemIndex = 0;


What is the correct syntax for setting the rg to 0?


--------------------
The syntax you are using is correct. But it lets you set "rg" to 0=None.
If you want to set it as never used including None, here is an example.
-------------------

It looks like there is an error. "-1" and 2-3 or -1 correspond to miscalculation.
If the DB does not offer a different approach to this situation, here is a solution;

Let's leave a function to list on first occurrence and clean and reuse it as needed.

Code:
   self.characters_rg = createRadioGroup(self.form);
   self.characters_rg.height = 205;
   self.characters_rg.width = 75;
   self.characters_rg.top = 90;
   self.characters_rg.left = 5;
   self.characters_rg.Caption = "Hero";

   function ClearCrtItem()
   self.characters_rg.getItems().Clear()
    for character,_ in pairs(self.Data.Characters) do
      if tonumber(character) then
         self.characters_rg.getItems().add(_);
      end
    end
   end
   ClearCrtItem()

   self.characters_rg.onClick =    function (sender)
   
   end


Use:
Code:
   self.profession_rg.onClick =    function (sender)
                                    index = strings_getString(sender.getItems(), sender.ItemIndex); --heroprof
                                    i = "";
                                    i = sender.ItemIndex --self.Data.Profession[index]+ 1; -- If the character does not hold the value,, i remains nil.
                                    print(i)
                                    if i~=0 then
                                     --for k,v in pairs (self.Data.Stats) do
                                       -- if k==index then
                                       --    i = v+1 -- We placed a value from 0 to 7 into the Characters name in the table.. but our stats is placed from 1 to 8 (alternative we could force the index in the table);
                                        --end
                                     --end
                                     --if i then
                                       heroprof = index--;index = heroprof;--heroname = index;
                                       print("The index selected is", self.Data.Stats[index]);
                                       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]);
                                       end
                                       --self.listview.visible=true
                                     --end
                                     else
                                     self.listview.clear();
                                     ClearCrtItem()  -->> here ..
                                     print(i .. " None")
                                    end
                                 end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Thu Mar 03, 2022 8:19 am    Post subject: Reply with quote

I just commented it out, saved and hit the execute script button and still have the error. Open the LUA debugger, and it still stops executing in the data section, execute script once more and I find error in the tstop timer
Code:

   tstop = createTimer(nil)
   timer_setInterval(t, 1000)
   timer_setEnabled(tstop, true)--tstop.Enabled = true
   timer_onTimer = function(tstop)
                      if(getOpenedProcessID() ~= 0)
                      and (readInteger("kernel32.dll") == nil) then
                         closeCE()
                      end
                   end

I wonder if it is a function of ver. 6.7, I have 7.3 installed I'll try that one and report back.
Commented out the tstop timer and no errors

ETA: Moved the tstop up one function and no errors, so all is good.
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
Goto page Previous  1, 2
Page 2 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