 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 619
|
Posted: Mon Nov 30, 2026 10:42 am Post subject: When does lua find Invalid Class Object |
|
|
I have a question as to when Lua finds an Invalid Class object?
In my current project. As earlier posted I've defined a cheat panel and displayed same. Then I have two function below that cheat panel build. When executed the panel displays. The first function is complete and works fine. The second function in values displaying values in the respective edit boxes and has a timer set to enable. After the time limit I start getting the error messages, so I added a bunch of print statements into the defining portion of the function. None of the print are ever executed, just the errors.
So when does lua "find" an invalid class object?
When the code is loaded?
When the code is executed?
| Code: |
trainer = trainer or {}
--
function Build_Cheat_Panel()
trainer.form = createForm(true);
setProperty(trainer.form , "BiDiMode", "bdLeftToRight");
trainer.form.Caption = 'Cheat Panel';
trainer.form.Width = 450;
trainer.form.Height = 460;
trainer.form.Left = 700;
trainer.form.Top =5;
--
trainer.value_panel1 = createPanel(trainer.form);
trainer.value_panel1.Caption = '';
trainer.value_panel1.left = 5;
trainer.value_panel1.top = 5;
trainer.value_panel1.Height = 35;
trainer.value_panel1.Width = 120;
--
trainer.value_panel2 = createPanel(trainer.form);
trainer.value_panel2.Caption = '';
trainer.value_panel2.left = 5;
trainer.value_panel2.top = 45;
trainer.value_panel2.Height = 35;
trainer.value_panel2.Width = 120;
--
--trainer.value_panel3 = createPanel(trainer.form)
--trainer.value_panel3.Caption = '';
--trainer.value_panel3.left = 5;
--trainer.value_panel3.top = 85;
--trainer.value_panel3.Height = 35;
--trainer.value_panel3.Width = 120;
--
trainer.exp_value = createEdit(trainer.value_panel1);
trainer.exp_value.top = 3;
trainer.exp_value.left = 10;
trainer.exp_value.Width = 105;
trainer.exp_value.Height = 23;
-- The line below this, allows only numbers or the - number to be entered.
--setMethodProperty(trainer.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; trainer.set_exp.onClick();
--
trainer.gold_value = createEdit(trainer.value_panel2);
trainer.gold_value.top = 3;
trainer.gold_value.left = 10;
trainer.gold_value.Width = 105;
trainer.gold_value.Height = 23;
-- The line below this, allows only numbers or the - number to be entered.
--setMethodProperty(trainer.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; trainer.set_exp.onClick();
--end
--
--trainer.Hp_value = createEdit(trainer.value_panel3);
--trainer.Hp_value.top = 3;
--trainer.Hp_value.left = 10;
--trainer.Hp_value.Width = 105;
--trainer.Hp_value.Height = 23;
--end
--
trainer.Level = createLabel(trainer.form);
trainer.Level.top = 10;
trainer.Level.left = 300;
trainer.Level.Width = 25;
trainer.Level.Height = 20;
trainer.Level.Caption = "Lvl"
--
trainer.EnemyCurHp = createLabel(trainer.form);
trainer.EnemyCurHp.top = 220;
trainer.EnemyCurHp.left = 350;
trainer.EnemyCurHp.Width = 50;
trainer.EnemyCurHp.Height = 20;
trainer.EnemyCurHp.Caption = "Enemy Cur Hp"
--
trainer.Enemy1 = createLabel(trainer.form);
trainer.Enemy1.top = 250;
trainer.Enemy1.left = 370;
trainer.Enemy1.Width = 30;
trainer.Enemy1.Height = 20;
trainer.Enemy1.Caption = "One"
--
trainer.Enemy2 = createLabel(trainer.form);
trainer.Enemy2.top = 280;
trainer.Enemy2.left = 370;
trainer.Enemy2.Width = 30;
trainer.Enemy2.Height = 20;
trainer.Enemy2.Caption = "Two"
--
trainer.Enemy3 = createLabel(trainer.form);
trainer.Enemy3.top = 310;
trainer.Enemy3.left = 370;
trainer.Enemy3.Width = 30;
trainer.Enemy3.Height = 20;
trainer.Enemy3.Caption = "Three"
--
trainer.Enemy4 = createLabel(trainer.form);
trainer.Enemy4.top = 340;
trainer.Enemy4.left = 370;
trainer.Enemy4.Width = 30;
trainer.Enemy4.Height = 20;
trainer.Enemy4.Caption = "Four"
--
trainer.Enemy5 = createLabel(trainer.form);
trainer.Enemy5.top = 370;
trainer.Enemy5.left = 370;
trainer.Enemy5.Width = 30;
trainer.Enemy5.Height = 20;
trainer.Enemy5.Caption = "Five"
--
trainer.Enemy6 = createLabel(trainer.form);
trainer.Enemy6.top = 400;
trainer.Enemy6.left = 370;
trainer.Enemy6.Width = 30;
trainer.Enemy6.Height = 20;
trainer.Enemy6.Caption = "Six"
--
trainer.Hero01 = createLabel(trainer.form);
trainer.Hero01.top = 40;
trainer.Hero01.left = 240;
trainer.Hero01.Width = 30;
trainer.Hero01.Height = 20;
trainer.Hero01.Caption = "Terra"
--
trainer.Hero02 = createLabel(trainer.form);
trainer.Hero02.top = 70;
trainer.Hero02.left = 240;
trainer.Hero02.Width = 30;
trainer.Hero02.Height = 20;
trainer.Hero02.Caption = "Locke"
--
trainer.Hero03 = createLabel(trainer.form);
trainer.Hero03.top = 100;
trainer.Hero03.left = 240;
trainer.Hero03.Width = 30;
trainer.Hero03.Height = 20;
trainer.Hero03.Caption = "Edgar"
--
trainer.Hero04 = createLabel(trainer.form);
trainer.Hero04.top = 130;
trainer.Hero04.left = 240;
trainer.Hero04.Width = 30;
trainer.Hero04.Height = 20;
trainer.Hero04.Caption = "Sabin"
--0
trainer.Hero05 = createLabel(trainer.form);
trainer.Hero05.top = 160;
trainer.Hero05.left = 240;
trainer.Hero05.Width = 30;
trainer.Hero05.Height = 20;
trainer.Hero05.Caption = "Shadow"
--
trainer.Hero06 = createLabel(trainer.form);
trainer.Hero06.top = 190;
trainer.Hero06.left = 240;
trainer.Hero06.Width = 30;
trainer.Hero06.Height = 20;
trainer.Hero06.Caption = "Celes"
--
trainer.Hero07 = createLabel(trainer.form);
trainer.Hero07.top = 220;
trainer.Hero07.left = 240;
trainer.Hero07.Width = 30;
trainer.Hero07.Height = 20;
trainer.Hero07.Caption = "Cyan"
--
trainer.Hero08 = createLabel(trainer.form);
trainer.Hero08.top = 250;
trainer.Hero08.left = 240;
trainer.Hero08.Width = 30;
trainer.Hero08.Height = 20;
trainer.Hero08.Caption = "Gau"
--
trainer.Hero09 = createLabel(trainer.form);
trainer.Hero09.top = 280;
trainer.Hero09.left = 240;
trainer.Hero09.Width = 30;
trainer.Hero09.Height = 20;
trainer.Hero09.Caption = "Setzer"
--
trainer.Hero10 = createLabel(trainer.form);
trainer.Hero10.top = 310;
trainer.Hero10.left = 240;
trainer.Hero10.Width = 30;
trainer.Hero10.Height = 20;
trainer.Hero10.Caption = "Strago"
--
trainer.Hero11 = createLabel(trainer.form);
trainer.Hero11.top = 340;
trainer.Hero11.left = 240;
trainer.Hero11.Width = 30;
trainer.Hero11.Height = 20;
trainer.Hero11.Caption = "Relm"
--
trainer.Hero12 = createLabel(trainer.form);
trainer.Hero12.top = 370;
trainer.Hero12.left = 240;
trainer.Hero12.Width = 30;
trainer.Hero12.Height = 20;
trainer.Hero12.Caption = "Mog"
--
trainer.Hero13 = createLabel(trainer.form);
trainer.Hero13.top = 400;
trainer.Hero13.left = 240;
trainer.Hero13.Width = 30;
trainer.Hero13.Height = 20;
trainer.Hero13.Caption = "Gogo"
--
trainer.Hero14 = createLabel(trainer.form);
trainer.Hero14.top = 430;
trainer.Hero14.left = 240;
trainer.Hero14.Width = 30;
trainer.Hero14.Height = 20;
trainer.Hero14.Caption = "Umaro"
--
trainer.EnemySixHp = createEdit(trainer.form);
trainer.EnemySixHp.top = 400;
trainer.EnemySixHp.left = 410;
trainer.EnemySixHp.Width = 30;
trainer.EnemySixHp.Height = 20;
--
trainer.EnemyFiveHp = createEdit(trainer.form);
trainer.EnemyFiveHp.top = 370;
trainer.EnemyFiveHp.left = 410;
trainer.EnemyFiveHp.Width = 30;
trainer.EnemyFiveHp.Height = 20;
--
trainer.EnemyFourHp = createEdit(trainer.form);
trainer.EnemyFourHp.top = 340;
trainer.EnemyFourHp.left = 410;
trainer.EnemyFourHp.Width = 30;
trainer.EnemyFourHp.Height = 20;
--
trainer.EnemyThreeHp = createEdit(trainer.form);
trainer.EnemyThreeHp.top = 310;
trainer.EnemyThreeHp.left = 410;
trainer.EnemyThreeHp.Width = 30;
trainer.EnemyThreeHp.Height = 20;
--
trainer.EnemyTwoHp = createEdit(trainer.form);
trainer.EnemyTwoHp.top = 280;
trainer.EnemyTwoHp.left = 410;
trainer.EnemyTwoHp.Width = 30;
trainer.EnemyTwoHp.Height = 20;
--
trainer.EnemyOneHp = createEdit(trainer.form);
trainer.EnemyOneHp.top = 250;
trainer.EnemyOneHp.left = 410;
trainer.EnemyOneHp.Width = 30;
trainer.EnemyOneHp.Height = 20;
--
trainer.HeroFourteenLvl = createEdit(trainer.form);
trainer.HeroFourteenLvl.top = 430;
trainer.HeroFourteenLvl.left = 300;
trainer.HeroFourteenLvl.Width = 30;
trainer.HeroFourteenLvl.Height = 20;
--
trainer.HeroThirteenLvl = createEdit(trainer.form);
trainer.HeroThirteenLvl.top = 400;
trainer.HeroThirteenLvl.left = 300;
trainer.HeroThirteenLvl.Width = 30;
trainer.HeroThirteenLvl.Height = 20;
--
trainer.HeroTwelveLvl = createEdit(trainer.form);
trainer.HeroTwelveLvl.top = 370;
trainer.HeroTwelveLvl.left = 300;
trainer.HeroTwelveLvl.Width = 30;
trainer.HeroTwelveLvl.Height = 20;
--
trainer.HeroElevenLvl = createEdit(trainer.form);
trainer.HeroElevenLvl.top = 340;
trainer.HeroElevenLvl.left = 300;
trainer.HeroElevenLvl.Width = 30;
trainer.HeroElevenLvl.Height = 20;
--
trainer.HeroTenLvl = createEdit(trainer.form);
trainer.HeroTenLvl.top = 310;
trainer.HeroTenLvl.left = 300;
trainer.HeroTenLvl.Width = 30;
trainer.HeroTenLvl.Height = 20;
--
trainer.HeroNineLvl = createEdit(trainer.form);
trainer.HeroNineLvl.top = 280;
trainer.HeroNineLvl.left = 300;
trainer.HeroNineLvl.Width = 30;
trainer.HeroNineLvl.Height = 20;
--
trainer.HeroEightLvl = createEdit(trainer.form);
trainer.HeroEightLvl.top = 250;
trainer.HeroEightLvl.left = 300;
trainer.HeroEightLvl.Width = 30;
trainer.HeroEightLvl.Height = 20;
--
trainer.HeroSevenLvl = createEdit(trainer.form);
trainer.HeroSevenLvl.top = 220;
trainer.HeroSevenLvl.left = 300;
trainer.HeroSevenLvl.Width = 30;
trainer.HeroSevenLvl.Height = 20;
--
trainer.HeroSixLvl = createEdit(trainer.form);
trainer.HeroSixLvl.top = 190;
trainer.HeroSixLvl.left = 300;
trainer.HeroSixLvl.Width = 30;
trainer.HeroSixLvl.Height = 20;
--
trainer.HeroFiveLvl = createEdit(trainer.form);
trainer.HeroFiveLvl.top = 160;
trainer.HeroFiveLvl.left = 300;
trainer.HeroFiveLvl.Width = 30;
trainer.HeroFiveLvl.Height = 20;
--
trainer.HeroFourLvl = createEdit(trainer.form);
trainer.HeroFourLvl.top = 130;
trainer.HeroFourLvl.left = 300;
trainer.HeroFourLvl.Width = 30;
trainer.HeroFourLvl.Height = 20;
--
trainer.HeroThreeLvl = createEdit(trainer.form);
trainer.HeroThreeLvl.top = 100;
trainer.HeroThreeLvl.left = 300;
trainer.HeroThreeLvl.Width = 30;
trainer.HeroThreeLvl.Height = 20;
--
trainer.HeroTwoLvl = createEdit(trainer.form);
trainer.HeroTwoLvl.top = 70;
trainer.HeroTwoLvl.left = 300;
trainer.HeroTwoLvl.Width = 30;
trainer.HeroTwoLvl.Height = 20;
--
trainer.HeroOneLvl = createEdit(trainer.form);
trainer.HeroOneLvl.top = 40;
trainer.HeroOneLvl.left = 300;
trainer.HeroOneLvl.Width = 30;
trainer.HeroOneLvl.Height = 20;
end--Build_Cheat_Panel()
Build_Cheat_Panel()
function MaxHP()
al=getAddressList()
enemy1curhpaddress = addresslist_getMemoryRecordByDescription(al, "Enemy 1 Cur HP")
enemy2curhpaddress = addresslist_getMemoryRecordByDescription(al, "Enemy 2 Cur HP")
enemy3curhpaddress = addresslist_getMemoryRecordByDescription(al, "Enemy 3 Cur HP")
enemy4curhpaddress = addresslist_getMemoryRecordByDescription(al, "Enemy 4 Cur HP")
enemy5curhpaddress = addresslist_getMemoryRecordByDescription(al, "Enemy 5 Cur HP")
enemy6curhpaddress = addresslist_getMemoryRecordByDescription(al, "Enemy 6 Cur HP")
BattleByte = addresslist_getMemoryRecordByDescription(al, "Battle Byte")
--
if tonumber(memoryrecord_getValue(BattleByte)) == 0 then
--print("the cur hp for #1 is",memoryrecord_getValue(enemy1curhpaddress))
if tonumber(memoryrecord_getValue(enemy1curhpaddress)) ~= 0 then
trainer.Enemy1 = memoryrecord_setValue(enemy1curhpaddress, 1)
end
if tonumber(memoryrecord_getValue(enemy2curhpaddress)) ~= 0 then
memoryrecord_setValue(enemy2curhpaddress, 1)
end
if tonumber(memoryrecord_getValue(enemy3curhpaddress)) ~= 0 then
memoryrecord_setValue(enemy3curhpaddress, 1)
end
if tonumber(memoryrecord_getValue(enemy4curhpaddress)) ~= 0 then
memoryrecord_setValue(enemy4curhpaddress, 1)
end
if tonumber(memoryrecord_getValue(enemy5curhpaddress)) ~= 0 then
memoryrecord_setValue(enemy5curhpaddress, 1)
end
if tonumber(memoryrecord_getValue(enemy6curhpaddress)) ~= 0 then
memoryrecord_setValue(enemy6curhpaddress, 1)
end
end
end--MaxHP()
--
trainer.tgm = createTimer(nil);
trainer.tgm.Interval = 1000;
trainer.tgm.onTimer =MaxHP
trainer.tgm.Enabled = false;
--
trainer.gm_cb = createCheckBox(trainer.form);
trainer.gm_cb.Caption = 'God Mode';
trainer.gm_cb.Height = 20;
trainer.gm_cb.Left = 350;
trainer.gm_cb.Width = 75;
trainer.gm_cb.Top = 7;
trainer.gm_cb.onClick = function (sender)
if sender.Checked then
trainer.tgm.Enabled = true;
print("God mode is enabled")
else
trainer.tgm.Enabled = false;
print("God mode is not enabled")
end
end
--
function DisplayEdits(sender)
--print("the display edits are enabled")
local AL = getAddressList();
battlescreen1address = tonumber(addresslist_getMemoryRecordByDescription(AL, "Battle Byte"))
battlescreen = memoryrecord_getValue(battlescreen1address)
print("get battle byte value")
HeroOneLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Terra Level"));
print("Get terra lvl")
HeroTwoLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Locke Level"));
print("Get locke lvl")
HeroThreeLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Cyan Level"));
print("get cyan lvl")
HeroFourLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Shadow Level"));
print("get shadow lvl")
HeroFiveLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Edgar Level"));
print("get edgar lvl")
HeroSixLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Sabin Level"));
print("get sabin lvl")
HeroSevenLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Celes Level"));
print("get celes lvl")
HeroEightLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Strago Level"));
print("get strago lvl")
HeroNineLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Relm Level"));
print("get relm lvl")
HeroTenLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Setzer Level"));
print("get setzer lvl")
HeroElevenLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Mog Level"));
print("get mog lvl")
HeroTwelveLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Gau Level"));
print("get gau lvl")
HeroThirteenLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Gogo Level"));
print("get gog lvl")
HeroFourteenLvl = memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Umaro Level"));
print("finished hero lvl")
--
enemyone = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Enemy 1 Cur HP")));
enemytwo = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Enemy 2 Cur HP")));
enemythree = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Enemy 3 Cur HP")));
enemyfour = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Enemy 4 Cur HP")));
enemyfive = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Enemy 5 Cur HP")));
enemysix = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "Enemy 6 Cur HP")));
print("finished enemy hp")
--
trainer.HeroOneLvl.Value = HeroOneLvl
trainer.HeroTwoLvl.Value = HeroTwoLvl
trainer.HeroThreeLvl.Value = HeroThreeLvl
trainer.HeroFourLvl.Value = HeroFourLvl
trainer.HeroFiveLvl.Value = HeroFiveLvl
trainer.HeroSixLvl.Value = HeroSixLvl
trainer.HeroSevenLvl.Value = HeroSevenLvl
trainer.HeroEightLvl.Value = HeroEightLvl
trainer.HeroNineLvl.Value = HeroNineLvl
trainer.HeroTenLvl.Value = HeroTenLvl
trainer.HeroElevenLvl.Value = HeroElevenLvl
trainer.HeroTwelveLvl.Value = HeroTwelveLvl
trainer.HeroThirteenLvl.Value = HeroThirteenLvl
trainer.HeroFourteenLvl.Value = HeroFourteenLvl
print("finished assigning hero edit box")
--
if tonumber(battlescreen) == 0 then
trainer.EnemyOneHp.Value = enemyone
trainer.EnemyTwoHp.Value = enemytwo
trainer.EnemyThreeHp.Value = enemythree
trainer.EnemyFourHp.Value = enemyfour
trainer.EnemyFiveHp.Value = enemyfive
trainer.EnemySixHp.Value = enemysix
end;
print("finished enemy edit box assigment")
end;--DisplayEdits(sender)
--
tde = createTimer(nil)
timer_onTimer(tde, DisplayEdits);--.Interval = 3000;
timer_setInterval(tde, 3000);--.onTimer = DisplayEdits
timer_setEnabled(tde, true);--.Enabled = false;
|
| Description: |
|
| Filesize: |
21.05 KB |
| Viewed: |
1008 Time(s) |

|
|
|
| Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 39
Joined: 16 Feb 2017 Posts: 1605
|
Posted: Tue Dec 01, 2026 1:36 pm Post subject: |
|
|
execute (click Execute button) = loaded ( load(code text) ()
At first glance, the control is not defined at the beginning, yet an "OnClick" event is assigned to it on line 42.
You need to define the control in the lines above before attempting to use it.
Please check for and correct any such errors.
Additionally, it seems "OnClick()" is being treated as a function argument; you might want to use "DoClick()" instead to simulate a click.
I will be able to share my final analysis once I’ve had a chance to test it on my PC.
| Code: | | trainer.set_exp.onClick() |
Here is a different mechanism for error testing:
| Code: | local function safeStartPanel(buildFunc)
-- Run inside pcall so runtime errors do not crash the caller
local ok, err = pcall(buildFunc)
if not ok then
-- Clean up partial form if creation failed midway
if trainer.form then
pcall(function() trainer.form.destroy() end)
trainer.form = nil
end
print("Build_Cheat_Panel failed: " .. tostring(err))
return false
end
-- No error: show/start the panel
if trainer.form then
trainer.form.show()
end
return true
end
-- Test and start only if no error occurred
safeStartPanel(Build_Cheat_Panel) |
_________________
|
|
| Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 619
|
Posted: Tue Dec 01, 2026 5:21 pm Post subject: |
|
|
| Those should have been commented out. Thet were used in a recalculation function, this table is attached/used with ZNESW, no recalculation is necessary. They are there but not used.
|
|
| Back to top |
|
 |
|
|
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
|
|