<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="17">
  <CheatEntries>
    <CheatEntry>
      <ID>0</ID>
      <Description>"bla"</Description>
      <LastState Value="??" Activated="0" RealAddress="00000000"/>
      <Color>80000008</Color>
      <VariableType>4 Bytes</VariableType>
      <Address/>
    </CheatEntry>
  </CheatEntries>
  <UserdefinedSymbols/>
  <LuaScript>errorOnLookupFailure(false) --this will cause pointer lookups to return nil, instead of raising an error and canceling the script

function lookupAddress()
  local offset=readInteger('[["GameModule.exe"+A9A858]+0x238]+0xA0'); --dereference the pointer and read the 4 byte value at that address

  if (offset~=nil) then
    offset=offset*8+4; --calculate the offset (result is an integer)
    local offsetstring=string.format("%x", offset)  --convert the integer to hexadecimal notation
    local addressString='[[["GameModule.exe"+AB7788]+0xC]+'..offsetstring..']+0x7C'  --build the addressString

    local r=getAddress(addressString)
    if (r~=nil) then
      return string.format("%x", r)
    else
      return nil
    end
  else
    return nil
  end


end

--cleanup the timer (in case the script gets executed multiple times for some reason)
if (updateTimer0~=nil) then
  updateTimer0.destroy()
  updateTimer0=nil
end

--create a timer to call lookupAddress() and fill in the address of the memory record with ID 0
--Memory record ID's are unique. No matter what entries you delete, and how you move them in the table, the ID will stay the same
updateTimer0=createTimer(nil)
updateTimer0.OnTimer=function(t)
  local mr=getAddressList().getMemoryRecordByID(0)
  mr.Address=lookupAddress()
end
updateTimer0.Interval=500
updateTimer0.Enabled=true
</LuaScript>
</CheatTable>
