 |
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: 616
|
Posted: Sat Nov 28, 2026 11:08 am Post subject: Smal bit of code that has an error that I can't recognize |
|
|
I have a small bit if code that has an error that I can't recognize.
[code]
function MaxHP()
al=getAddressList()
enemy1curhpaddress = addresslist_getMemoryRecordByDescription(al, "Enemy 1 Cur HP")
enemy2curhpaddress = addresslist_getMemoryRecordByDescription(al, "Enemy 2 Cur HP")
enemy4curhpaddress = 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")
print(tonumber(memoryrecord_getValue(enemy1curhpaddress)))
--
if tonumber(memoryrecord_getValue(enemy1curhpaddress)) ~= 65535 then
if tonumber(memoryrecord_getValue(enemy1curhpaddress)) ~= 21844 then
if tonumber(memoryrecord_getValue(enemy1curhpaddress)) ~= 17732 then
if tonumber(memoryrecord_getValue(enemy1curhpaddress)) ~= 0 then
print("the cur hp for #1 is",memoryrecord_getValue(enemy1curhpaddress))
memoryrecord_setValue(enemy1curhpaddress, 1)
end
end
end
end
print("the cur hp for #2 is",memoryrecord_getValue(enemy2curhpaddress))
if tonumber(memoryrecord_getValue(enemy2curhpaddress)) ~= 65535 then
if tonumber(memoryrecord_getValue(enemy2curhpaddress)) ~= 21844 then
if tonumber(memoryrecord_getValue(enemy2curhpaddress)) ~= 17732 then
if tonumber(memoryrecord_getValue(enemy2curhpaddress)) ~= 0 then
print("the cur hp for #2 is",memoryrecord_getValue(enemy2curhpaddress))
memoryrecord_setValue(enemy2curhpaddress, 1)
end
end
end
end
if tonumber(memoryrecord_getValue(enemy3curhpaddress)) ~= 65535 then
if tonumber(memoryrecord_getValue(enemy3curhpaddress)) ~= 21844 then
if tonumber(memoryrecord_getValue(enemy3curhpaddress)) ~= 17732 then
if tonumber(memoryrecord_getValue(enemy3curhpaddress)) ~= 0 then
print("the cur hp for #3 is",memoryrecord_getValue(enemy4curhpaddress))
memoryrecord_setValue(enemy3curhpaddress, 1)
end
end
end
end
if tonumber(memoryrecord_getValue(enemy4curhpaddress)) ~= 65535 then
if tonumber(memoryrecord_getValue(enemy4curhpaddress)) ~= 21844 then
if tonumber(memoryrecord_getValue(enemy4curhpaddress)) ~= 17732 then
if tonumber(memoryrecord_getValue(enemy4curhpaddress)) ~= 0 then
print("the cur hp for #4 is",memoryrecord_getValue(enemy4curhpaddress))
memoryrecord_setValue(enemy4curhpaddress, 1)
end
end
end
end
if tonumber(memoryrecord_getValue(enemy5curhpaddress)) ~= 65535 then
if tonumber(memoryrecord_getValue(enemy5curhpaddress)) ~= 21844 then
if tonumber(memoryrecord_getValue(enemy5curhpaddress)) ~= 17732 then
if tonumber(memoryrecord_getValue(enemy5curhpaddress)) ~= 0 then
print("the cur hp for #5 is",memoryrecord_getValue(enemy5curhpaddress))
memoryrecord_setValue(enemy5curhpaddress, 1)
end
end
end
end
if tonumber(memoryrecord_getValue(enemy6curhpaddress)) ~= 65535 then
if tonumber(memoryrecord_getValue(enemy6curhpaddress)) ~= 21844 then
if tonumber(memoryrecord_getValue(enemy6curhpaddress)) ~= 17732 then
if tonumber(memoryrecord_getValue(enemy6curhpaddress)) ~= 0 then
print("the cur hp for #6 is",memoryrecord_getValue(enemy6curhpaddress))
memoryrecord_setValue(enemy6curhpaddress, 1)
end
end
end
end
end--MaxHP()
This code is run under a timer "God Mode". It is obvious that the first part for enemy #1 works/ed as the value was not 1 in the first attempt. The error must in my mind be the second if statement for enemy #2, since the print statement for #2 never gets executed. In fact I added another print statement for #1 just prior to the print for #2 and it doesn't print either. that lack of print was not shown in attachment, and that deepens my lack of understanding.
| Description: |
|
| Filesize: |
9.4 KB |
| Viewed: |
4541 Time(s) |

|
| Description: |
|
| Filesize: |
10.59 KB |
| Viewed: |
4541 Time(s) |

|
|
|
| Back to top |
|
 |
Csimbi I post too much
Reputation: 99
Joined: 14 Jul 2007 Posts: 3443
|
Posted: Sat Nov 28, 2026 1:25 pm Post subject: |
|
|
| I would start with replacing all those tonumber calls with just one, storing the return value in a local and checking it for nil.
|
|
| Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 616
|
Posted: Sat Nov 28, 2026 1:58 pm Post subject: |
|
|
| How would that help?
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 475
Joined: 09 May 2003 Posts: 26037 Location: The netherlands
|
Posted: Sat Nov 28, 2026 3:23 pm Post subject: |
|
|
reload the table and confirm that enemy2curhpaddress is not nil
(you never set enemy3curhpaddress but since it fails before that maybe the description cache hasn't been refreshed
also your print(tonumber(memoryrecord_getValue(enemy1curhpaddress))) is never shown
_________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 616
|
Posted: Sun Nov 29, 2026 8:12 am Post subject: |
|
|
Oh boy after restarting table, game. That must be the order, since game crashes if opened first. Anyway After opening I get a dozen invalid class object then that stops. Here is all the code
| 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;
--
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;
--
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;
----
trainer.Level = createLabel(trainer.form);
trainer.Level.top = 115;
trainer.Level.left = 85;
trainer.Level.Width = 25;
trainer.Level.Height = 20;
trainer.Level.Caption = "Lvl"
--
trainer.HeroOneEdit = createEdit(trainer.form);
trainer.HeroOneEdit.top = 161;
trainer.HeroOneEdit.left = 100;
trainer.HeroOneEdit.Width = 30;
trainer.HeroOneEdit.Height = 20;
--
trainer.HeroTwoEdit = createEdit(trainer.form);
trainer.HeroTwoEdit.top = 189;
trainer.HeroTwoEdit.left = 100;
trainer.HeroTwoEdit.Width = 30;
trainer.HeroTwoEdit.Height = 20;
--
trainer.HeroThreeEdit = createEdit(trainer.form);
trainer.HeroThreeEdit.top = 217;
trainer.HeroThreeEdit.left = 100;
trainer.HeroThreeEdit.Width = 30;
trainer.HeroThreeEdit.Height = 20;
--
trainer.HeroFourEdit = createEdit(trainer.form);
trainer.HeroFourEdit.top = 245;
trainer.HeroFourEdit.left = 100;
trainer.HeroFourEdit.Width = 30;
trainer.HeroFourEdit.Height = 20;
--
trainer.HeroFiveEdit = createEdit(trainer.form);
trainer.HeroFiveEdit.top = 270;
trainer.HeroFiveEdit.left = 100;
trainer.HeroFiveEdit.Width = 30;
trainer.HeroFiveEdit.Height = 20;
--
trainer.HeroSixEdit = createEdit(trainer.form);
trainer.HeroSixEdit.top = 295;
trainer.HeroSixEdit.left = 100;
trainer.HeroSixEdit.Width = 30;
trainer.HeroSixEdit.Height = 20;
--
end--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")
--
if tonumber(memoryrecord_getValue(enemy1curhpaddress)) ~= 65535 then
if tonumber(memoryrecord_getValue(enemy1curhpaddress)) ~= 21844 then
if tonumber(memoryrecord_getValue(enemy1curhpaddress)) ~= 17732 then
if tonumber(memoryrecord_getValue(enemy1curhpaddress)) ~= 0 then
print("the cur hp for #1 is",memoryrecord_getValue(enemy1curhpaddress))
memoryrecord_setValue(enemy1curhpaddress, 1)
end
end
end
end
if tonumber(memoryrecord_getValue(enemy2curhpaddress)) ~= 65535 then
if tonumber(memoryrecord_getValue(enemy2curhpaddress)) ~= 21844 then
if tonumber(memoryrecord_getValue(enemy2curhpaddress)) ~= 17732 then
if tonumber(memoryrecord_getValue(enemy12curhpaddress)) ~= 0 then
memoryrecord_setValue(enemy2curhpaddress, 1)
end
end
end
end
if tonumber(memoryrecord_getValue(enemy3curhpaddress)) ~= 65535 then
if tonumber(memoryrecord_getValue(enemy3curhpaddress)) ~= 21844 then
if tonumber(memoryrecord_getValue(enemy3curhpaddress)) ~= 17732 then
if tonumber(memoryrecord_getValue(enemy3curhpaddress)) ~= 0 then
memoryrecord_setValue(enemy3curhpaddress, 1)
end
end
end
end
if tonumber(memoryrecord_getValue(enemy4curhpaddress)) ~= 65535 then
if tonumber(memoryrecord_getValue(enemy4curhpaddress)) ~= 21844 then
if tonumber(memoryrecord_getValue(enemy4curhpaddress)) ~= 17732 then
if tonumber(memoryrecord_getValue(enemy4curhpaddress)) ~= 0 then
memoryrecord_setValue(enemy4curhpaddress, 1)
end
end
end
end
if tonumber(memoryrecord_getValue(enemy4curhpaddress)) ~= 65535 then
if tonumber(memoryrecord_getValue(enemy5curhpaddress)) ~= 21844 then
if tonumber(memoryrecord_getValue(enemy5curhpaddress)) ~= 17732 then
if tonumber(memoryrecord_getValue(enemy5curhpaddress)) ~= 0 then
memoryrecord_setValue(enemy5curhpaddress, 1)
end
end
end
end
if tonumber(memoryrecord_getValue(enemy4curhpaddress)) ~= 65535 then
if tonumber(memoryrecord_getValue(enemy6curhpaddress)) ~= 21844 then
if tonumber(memoryrecord_getValue(enemy6curhpaddress)) ~= 17732 then
if tonumber(memoryrecord_getValue(enemy6curhpaddress)) ~= 0 then
memoryrecord_setValue(enemy6curhpaddress, 1)
end
end
end
end
end--MaxHP()
t = createTimer(nil, true);
timer_onTimer(t, MaxHP);
timer_setInterval(t, 500);--check every 500 milliseconds
timer_setEnabled(t, true)
|
After entering a battle there are errors as in the image, . it appears as though the MaxHP() coded is running without thespaghetti monstermode being checked. It did execute the first enemy but not the second or third.
Since the code is running what is the proper sequence of the timer, checking whether the box has been checked and function to execute?
CE continued with the error printing until it reached some value as then stopped saving an exception auto save.
| Description: |
|
| Filesize: |
155.74 KB |
| Viewed: |
2851 Time(s) |

|
| Description: |
|
| Filesize: |
53.85 KB |
| Viewed: |
2851 Time(s) |

|
|
|
| Back to top |
|
 |
Frouk Grandmaster Cheater
Reputation: 6
Joined: 22 Jun 2021 Posts: 536
|
Posted: Sun Nov 29, 2026 8:32 am Post subject: |
|
|
line
| Code: | | if tonumber(memoryrecord_getValue(enemy12curhpaddress)) ~= 0 then |
is the issue the code does not work, should be enemy2curhpaddress rather than enemy12curhpaddress
and I also see that in the code that there's literally unchanged variables in conditions, after the fourth one it still checks for 5th and the 6 one
I would recommend using the for loop to retrieve the memory records and set their value, as well as use the method for getAddressList rather than access the static method
|
|
| Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 616
|
Posted: Sun Nov 29, 2026 11:58 am Post subject: |
|
|
| Frouk wrote: |
line
| Code: | | if tonumber(memoryrecord_getValue(enemy12curhpaddress)) ~= 0 then |
is the issue the code does not work, should be enemy2curhpaddress rather than enemy12curhpaddress
and I also see that in the code that there's literally unchanged variables in conditions, after the fourth one it still checks for 5th and the 6 one
I would recommend using the for loop to retrieve the memory records and set their value, as well as use the method for getAddressList rather than access the static method |
That would certainly account for Invalid class object since that doesn't exist.
It is interesting there are two tabs on the code page tab1 has that error and has been fixed, tab 3 doesn't have that error. Not sure why there are two tabs but it has been repaired and we'll see what happens when I start the code.
Thaks
|
|
| Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 76
Joined: 10 Apr 2015 Posts: 1681
|
Posted: Sun Nov 29, 2026 6:08 pm Post subject: |
|
|
| Code: |
function MaxHP()
local al = getAddressList()
for i = 1, 6 do
local desc = "Enemy " .. i .. " Cur HP"
local rec = al.getMemoryRecordByDescription(desc)
if rec ~= nil then
local val = tonumber(rec.Value)
if val ~= nil and val ~= 65535 and val ~= 21844 and val ~= 17732 and val ~= 0 then
rec.Value = 1
end
else
error("Address not found: " .. desc)
end
end
end
-- Timer control, to stop timer when error found. Use pcall
if t ~= nil then
t.destroy()
t = nil
end
t = createTimer(nil, true)
t.Interval = 500
t.OnTimer = function(timer)
local status, err = pcall(MaxHP)
if not status then
timer.Enabled = false
timer.destroy()
t = nil
print("Timer has stopped because error:", err)
end
end
t.Enabled = true
|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
| 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
|
|