Page 1 of 1

count of subrecords

Posted: Fri Jul 07, 2023 10:03 am
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.

Re: I need some help!

Posted: Thu Jul 20, 2023 8:35 am
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

Re: count of subrecords

Posted: Thu Jul 20, 2023 9:20 am
by Cas
ares0814 wrote:
Fri Jul 07, 2023 10:03 am
..
Don’t use clickbait titles.

Re: count of subrecords

Posted: Sun Mar 31, 2024 12:53 pm
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?

Re: count of subrecords

Posted: Sun Mar 31, 2024 11:20 pm
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