Page 1 of 1

How can I add addresses to address list in the main GUI properly?

Posted: Fri Jan 26, 2024 4:58 pm
by QueryBrownie
Hi everyone,
Recently I was learning how to make some automated code to simplify modifications.
And I was able to figure out how to do AOB Scan, etc, etc.
But there is one question: I was not able to add those already-found addresses into the main GUI's memory records properly.

Here's my script.

Code: Select all

{$lua}
if syntaxcheck then return end

local addrLst = getAddressList()

[ENABLE]
scan = AOBScan("D4 C2 D9 A2 BF 46 BA 71 DE 18 A1 BE F7 9B AE B1")
resultTotal = scan.Count
registerSymbol("TotalResults", resultTotal)

for i=1, resultTotal, 1 do
  local base = scan[i-1]
  local ptr = '['..base..']+56';

  registerSymbol("InvItem"..tostring(i), ptr)
  local address = getAddress(ptr)
  local description = "Inventory "..tostring(i).." Item Count"
  local mr = addrLst.createMemoryRecord()
  mr.Description = description
  mr.Address = ptr  -- This address is not added properly in the memory record.
  mr.Type = vtDword

  parentMR = addrLst.getMemoryRecordByDescription('Inventory Edit')
  if parentMR~=nil then mr.appendToEntry(parentMR) end

end

scan.destroy()

[DISABLE]
for i=1, resultTotal, 1 do
  unregisterSymbol("InvItem"..tostring(i))
  local description = "Inv " .. tostring(i) .. " Item Count"
  local recordsToDelete = {}
  local mr = addrLst.getMemoryRecordByDescription(description) -- How to delete those ones? This does not work. It says mr is nil.
  mr.free()
end
resultTotal = nil
unregisterSymbol("resultTotal")
In the "Symbol" view, I can see those addresses like "[1E644F07CCC]+56", but after the createMemoryRecord, it's showing a different address (very long and I suspect it's global memory address).
Also, the next commented line "How to delete those ones? This does not work." is another problem: I can't remove those items from the address list. What's the proper way to do this?

Re: How can I add addresses to address list in the main GUI properly?

Posted: Fri Jan 26, 2024 6:52 pm
by Paul44
^ if you are new in CE (and in combo with Lua in particular), then you are way over your head.
(if you ask me... which you don't 8-))

Anyways:
1. find my AC 4 Black Flag table, and check out the script [Ship Status ~ Ship Battles]. This adds entries upon enabling, and removes them upon disabling. (important to note: to remove entries, you have to LIFO ~= delete last, then pre-last (= the new last, if you will), etc...)

2. before even writing this up, start with 'print'-ing your findings/addresses first. and forget them registersymbol stuff, as you do not need it...

Tip: add an (image) example of your AOBscan, plus some found addresses, shown in the addresslist. And use 'string.format()' to properly shown them in your print_statement.