Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Searching for AOB and recalulating a saved table
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sat Jan 12, 2013 11:05 pm    Post subject: Reply with quote

Finally got the code to work. Note this is one a different game, Final Fantasy VI(III in US), but I was still working with an aray of bytes.

Code:
function CEButton1Click(CEButton1)
addresslist = getAddressList();
memrec1 = addresslist_getMemoryRecordByDescription(addresslist, "Terra Fire Spell");
--print("Terra Fire Spell Table Address", memrec1);
terrafirespell = memoryrecord_getAddress(memrec1);--Item in num format
--print("Terra Fire Spell memory address", terrafirespell, "which is ", string.format('%x', terrafirespell));
for x = 0, addresslist_getCount(addresslist)-1 do
memrec2 = addresslist_getMemoryRecord(addresslist, x);
--memrec3 = memoryrecord_getDescription(memrec2);
--print("Table address for record", x, "is", memrec2, "and the description is", memrec3);
if memrec2 == memrec1 then
--print("Table record", x, "description for is", memrec3);
for y = x, x + 647 do
memrec4 = addresslist_getMemoryRecord(addresslist, y);
--print(memrec4, memoryrecord_getDescription(memrec4), string.format('%x', memoryrecord_getAddress(memrec4)));
writeInteger(string.format('%x', memoryrecord_getAddress(memrec4)), 255)
end;
end;
end;
end;


With the function and last end lines removed it runs within the Lua script:Cheat Table. I created a form with two buttons. Button Two recalculates the table and the Button One sets spell values to 255 with the above code. Both work in the table but neither work using the form buttons. I get an error:attempt to call a nil value when the button is selected. On the events page the OnClick is set to the two buttons respectively(ie CEButton1Click)
Back to top
View user's profile Send private message Yahoo Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Jan 13, 2013 6:35 pm    Post subject: Reply with quote

Why don't the buttons in this example work? What is missing or what do I need to change to make it work? The only error message: attempt to call a nil value.


1-13-2013 6-07-06 PM.png
 Description:
 Filesize:  199.9 KB
 Viewed:  12473 Time(s)

1-13-2013 6-07-06 PM.png


Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Sun Jan 13, 2013 6:49 pm    Post subject: Reply with quote

Make sure you execute the script before clicking the button , so that cebutton1click becomes available
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Jan 13, 2013 7:15 pm    Post subject: Reply with quote

mmmmmm
Great that works, but brings three more questions:
1. When CE opens a saved list, there is a dialog box that pops up, do you want to run the script etc. This will enable the buttons to work?
2. Speaking of buttons there is a CESavedialog1 on the form(checked it inadvertenly). How to get rid of it? I get another dialo box confirming the deletion, but it never deletes. What does it do anyway.
3. How can one mak it visible and "live" when the saved list is opened?
Thanks--This has been gnawing at me for a couple of days
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Mon Jan 14, 2013 4:25 am    Post subject: Reply with quote

1: Yes, if you run that lua script the buttons will work. Also, if you save your .ct with .cetrainer extention it will automatically execute it without asking

2: Hmm, looks like a bug. Pressing delete in the object inspector should have removed it. A CESavedialog1 is an object that when the Execute method is invoked shows a dialogbox with a save button. When clicked it will return the path to the filename the user wants to save

3: In your script add code to show the form. E.g: form_show(CheatPanel)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Mon Jan 14, 2013 4:44 am    Post subject: Reply with quote

1. Would that be .cet?
3. Add the form_show(CheatPanel) at the very beginning, or after the the first function?
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Mon Jan 14, 2013 5:15 am    Post subject: Reply with quote

1: no, .cetrainer . Extensions can have any length you wish

3: As long as it's outside of a function it'll work, but I usually put it as last. (Not that it mentions much since the form won't receive input till the script has finished)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Mon Jan 14, 2013 5:50 am    Post subject: Reply with quote

Ah I never knew extension had no limit, I always thought it was a 3.
Back to top
View user's profile Send private message Yahoo Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Mon Jan 14, 2013 8:12 pm    Post subject: Reply with quote

A little different question relating to pointers same game, but may be used as a coding for a trainer. I have had this address for as long as I have had the table, but never able to get a pointer(s) for this operation. As soon as the pointer option is checked all I get is ????????, so what offset is needed? I tried the every value of registers, except obviously the correct one, the resultant is still ???????. What offset am I missing?


1-14-2013 7-32-32 PM.png
 Description:
 Filesize:  230.41 KB
 Viewed:  12392 Time(s)

1-14-2013 7-32-32 PM.png


Back to top
View user's profile Send private message Yahoo Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sat Jan 19, 2013 9:10 am    Post subject: Reply with quote

This code has worked since I installed 6.2 and tweaked the differences between 6.2 and 6.1, that is until last night.
Code:

function CEButton2Click(sender)
errorOnLookupFailure(false)
ms = createMemScan()
--Need to search for Array Of Bytes
--Terra does not exist from beginning of game, only after "naming" her after the first sequences of battles
--AOB for Terra after being named is 33 24 31 31 20 FF
--The key to recalculating should be 0x2E00 from Terra's name, location of second Terra address from memory
memscan_firstScan(ms, soExactValue, vtByteArray, rtRounded, "33 24 31 31 20 FF", "", 0x00000000, 0x7fffffff, "*X*C*W", fsmNotAligned, "", true, false, false, false);
memscan_waitTillDone(ms);
fl = createFoundList(ms);
foundlist_initialize(fl);
foundlist_getCount(fl);
print("num of search hits", foundlist_getCount(fl));
for x = 0, foundlist_getCount(fl)-1  do--Items are in the hex format (0125D60F) without 0x
memrec1 = foundlist_getAddress(fl, x);
--print("33 24 31 31 20 FF from foundlist_getAddress(fl, x)", memrec1);
memrec2 = "0x" .. memrec1;
secondterraaddress = memrec2 + 0x2E00;--Items are in the number format of the hex summation
--print("Search record number", x, " test menu options", secondterraaddress);
secondterraaddress = string.format('%x', secondterraaddress);--Items in number format converted to hex format without 0x
--print(table.concat(readBytes(secondterraaddress,6,true),', ',1));--returns an array of integers
if table.concat(readBytes(secondterraaddress,6,true),', ',1) == "51, 36, 49, 49, 32, 255" then--table.concat(table, sep, start, length)
--memrec2 = memrec2 + 0x000000--Items are in the number format of the hex summation
byteoffset = memrec2;--byteoffset is in the number format (104724002)
print("Terra address from memory", byteoffset,"which is in hex");
--print("Correct '33 24 31 31 20 FF' to recalculate table", byteoffset);
end;
end;
print("Byteoffset to correct table entries", byteoffset);
addresslist = getAddressList();
memrec3 = addresslist_getMemoryRecordByDescription(addresslist, "Terra Name (33 24 31 31 20 FF-Default)");
print("Terra from table", memrec3);
terratableaddress = memoryrecord_getAddress(memrec3);--Item in num format
--print("Terra current table address", string.format('%x', terratableaddress), "which is ",terratableaddress);
terratableaddress = string.format('%x', terratableaddress);--Items in number format converted to hex format without 0x
terratableaddress = "0x" .. terratableaddress

for x = 0, addresslist_getCount(addresslist)-1 do--addresslist_getCount(addresslist)-1 do
--memrec4 = addresslist_getMemoryRecordByID(addresslist, x);
memrec4 = addresslist_getMemoryRecord(addresslist, x);
if byteoffset ~= terratableaddress then
memoryrecord_setAddress(memrec4, string.format('%x', memoryrecord_getAddress(memrec4) + byteoffset - terratableaddress));
end;
end;
end;

Now it fails at the memory scan, finding no hits, yet I can copy the aob from the code and paste it into CE as normal and find 5 hits.
Thinking it may have been working with the form I deleted it but the same code errors occur. I have games and CE on another machine (Win 7) and the code works on it, so I copied the CE file onto this lap(Win Xp) and again the same code error occurs. I went back to the original developed with 6.1 (using 6.1) and THAT WORKS on this lap.
I don't understand what has happened and why it fails to find the aob.



CETCodeError.png
 Description:
 Filesize:  11.89 KB
 Viewed:  12274 Time(s)

CETCodeError.png


Back to top
View user's profile Send private message Yahoo Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Mon Jan 21, 2013 9:49 pm    Post subject: Reply with quote

My scheme of recalculating addresses is failing miserably in FF VII, so I went back to the chalk board.
If I do a search for "22 41 52 52 45 54 FF FF" (Barret) and find 7 hits (thankfully not 0):
Address 0 00F143D0
Address 1 00F163D0
Address 2 00F183D0
Address 3 00F1A3D0
Address 4 00F1C3D0
Address 5 00F1E3D0
Address 6 01DAC7EC

The last address is the correct address to adjust the table, but sometimes there is another address somewhere further in the game (that is how I searched for the correct "22 41 52 52 45 54 FF FF" originally).
So what I want to do is search for the last 3 or 4 characters of all the found addresses, not the values of the address because I have used the value to find these address.
I looked in lua and on the commands for CE, but haven't been able to locate something similar to:
if right(address, 3) == "7EC" then
--found the correct address--
How can this be accomplished?
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Tue Jan 22, 2013 3:56 am    Post subject: Reply with quote

check fastscan , set the editfield to 7EC and check "Last Digits"

to do this in lua in your firstscan you'll need to change
Code:

fsmNotAligned, ""

to
Code:

fsmLastDigits, "7EC"


(And it will speed up the scan a lot as well)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Tue Jan 22, 2013 8:42 am    Post subject: Reply with quote

This would work as well with:
for x = 0, foundlist_getCount(fl)-1 do
memrec1 = foundlist_getAddress(fl, x);


Because that is the addresses I'm searching for the last n characters?
Back to top
View user's profile Send private message Yahoo Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Wed Jan 23, 2013 10:27 pm    Post subject: Reply with quote

Well I have worked a couple of nights off and on and have been unable to make this work.
Code:
ms = createMemScan()
errorOnLookupFailure(false);
memscan_firstScan(ms, soExactValue, vtByteArray, rtRounded, "22 41 52 52 45 54 FF FF", "", "00000000", "7fffffff", "*X*C*W", fsmNotAligned, "", true, false, false, false);
memscan_waitTillDone(ms);
memscan_nextScan(ms, soExactValue, vtByteArray, rtRounded, "", "", "00000000", "7fffffff", "*X*C*W", fsmLastDigits, "7EC", true, false, false, false);
memscan_waitTillDone(ms);
fl = createFoundList(ms);
foundlist_initialize(fl);
foundlist_getCount(fl);

The first scan finds any where from 8-9 hits one of which has the last three hex 7EC. It is this one I'm trying to narrow down on the nextScan. I tried to duplicate with CE, and all the options are "greyed" out to change the params and refine the search.
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Thu Jan 24, 2013 1:29 am    Post subject: Reply with quote

That is because the fastscan parameter is for first scan only.You do the first scan with the lastDigits fastscan method so the only addresses you find end with 7ec
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites