count of subrecords

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
ares0814
What is cheating?
What is cheating?
Posts: 2
Joined: Fri Jul 07, 2023 9:32 am
Reputation: 0

count of subrecords

Post by ares0814 »

hi all,
I have a record that represents the categories of items in my game, and within each category, there are subRecords. I want to monitor the count of subRecords within each category to ensure it matches the corresponding value. For example, if I have 60 items, I expect there to be 60 subRecords. If the item count changes to 80, I want the subRecord count to increase to 80 as well.

I am aware of the timer-based approach to achieve this, but I'm interested in exploring alternative methods that do not rely on a timer. I would appreciate any suggestions or insights from the Cheat Engine community on different approaches to dynamically monitoring and adjusting the count of subRecords based on changes to the item count. If you have any code examples or alternative methods to propose, I would be grateful for your input. Thank you in advance for your assistance.

User avatar
Messy6666
Table Makers
Table Makers
Posts: 724
Joined: Fri Sep 25, 2020 5:45 pm
Reputation: 743

Re: I need some help!

Post by Messy6666 »

^
A general approach ( not LUA specific ) would be:
  • a) find out what writes to the "record that represents the categories of items"
  • b) hook it
  • c) write the same value also to the subRecords field

Cas
Expert Cheater
Expert Cheater
Posts: 263
Joined: Fri Mar 03, 2017 12:04 am
Reputation: 125

Re: count of subrecords

Post by Cas »

ares0814 wrote:
Fri Jul 07, 2023 10:03 am
..
Don’t use clickbait titles.

ares0814
What is cheating?
What is cheating?
Posts: 2
Joined: Fri Jul 07, 2023 9:32 am
Reputation: 0

Re: count of subrecords

Post by ares0814 »

Cas wrote:
Thu Jul 20, 2023 9:20 am
ares0814 wrote:
Fri Jul 07, 2023 10:03 am
..
Don’t use clickbait titles.
???what do you mean? i don't understand what the meaning of 'clickbait titles' you mentioned is?

panraven
Table Makers
Table Makers
Posts: 124
Joined: Fri Mar 03, 2017 12:03 am
Reputation: 112

Re: count of subrecords

Post by panraven »

Each record with 'Value' to be displayed (eg. not include script/group etc.) may attached a function to alter what it display.
The function is like an OnTimer function of a Timer, only enabled when the record can be 'seen', disabled when 'hidden' (eg. under a collapsed parent record). So it can be auto-update the displayed value in real time.

Code: Select all

MemoryRecord Class:
...
  OnGetDisplayValue: function(memoryrecord,valuestring):boolean,string - 
  This function gets called when rendering the value of a memory record. 
  Return true and a new string to override the value shown
test: make a record with description 'DISP', of string type, len 0. put some other records under it.
Run this script:

Code: Select all

local al = GetAddressList()
local mr = al.getMemoryRecordByDescription'DISP'
if mr then
  mr.OnGetDisplayValue = function(mr, val)
    return true, os.date'%X : ' .. mr.Count
  end
end
This will display a time and the number of its child count.

You may also loop through all child record, check that it is valid <sum to validCount>, then display as

Code: Select all

  return true, validCount..' / '.. mr.Count

Post Reply

Who is online

Users browsing this forum: disneypatch