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 


LUA help, please
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: Fri Dec 21, 2012 11:16 am    Post subject: Reply with quote

You must have esp, as I was thinking last night if there was a way to "find" the beginning of the emulator address.

I don't know how to find the beginning if the emulator, but the same problem would exist the addresses would have to be recalculated.
Back to top
View user's profile Send private message Yahoo Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Dec 21, 2012 9:16 pm    Post subject: Reply with quote

ms = createMemScan()
memscan_firstScan(ms, soExactValue, vtString, "", "Orrin", "", 0, 0xffffffffffffffff, fsmNotAligned, "", false, true, false, true);
fl = createFoundList(ms);
foundlist_getCount(fl);
foundlist_getAddress(fl, "");
for x = 1, foundlist_getCount(fl) do
if readString(foundlist_getAddress + 0x22c9e,4) == "Tiva" then
byteoffset = foundlist_GetAddress(fl, x);
--Should be the address to recalculate table addresses
end;
end;
addresslist = getAddressList();
memrec1 = addresslist_getMemoryRecordByDescription(addresslist, "Orrin");
orrinaddress = memoryrecord_getAddress(memrec1);
for x = 0, addresslist_getCount(addresslist)-1 do
memrec2 = addresslist_getMemoryRecordByID(addresslist, x);
if byteoffset >= orrinaddress then
--This line shows an error "attempt to compare a number with a nil"
memoryrecord_setAddress(memrec2, "0x".. memoryrecord_getAddress(memrec2) - "0x" .. byteoffset);
else
memoryrecord_setAddress(memrec2, "0x".. memoryrecord_getAddress(memrec2) + "0x" .. byteoffset);
end;
end;

If the code operates as believe it should, both should be hex addresses. The way the error READS byteoffset is a number and orrinaddress is a nil. Orrin is in the table, so that shouldn't be a nil but the code could be incorrect and it is nil becasue it does not reference the Description Orrin as I expected.
I looked for some debug print codes but couldn't find any. What methods are used in debugging a code sequence?

Edited: Changed the code in line #6 to:
for x = 0, foundlist_getCount(fl) -1 do

Same error on line 22

Edited 2:
I tinkered with the statement if byteoffset >= orrinaddress then
changing it to if "0x" .. byteoffset >= "0x" .. orrinaddress then
and got a different error code "attempt to concatenate global 'byteoffset' (a nil value)--So this is where the error occurred.
For information Orrin occurs three times:
0x011BD058
0x0125D60F--this is the one that is in the table of entries
0x01342C60
Tiva is in the table three times as well:
0x012802AD--This is the one in the table of entries 0x22C9E from Orrin
0x012C0590
0x013497B3
So what is wrong with line 7(maybe line 2)?
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sun Dec 23, 2012 4:00 am    Post subject: Reply with quote

if readString(foundlist_getAddress + 0x22c9e,4) == "Tiva" then

You're not providing parameters to foundlist_getAddress

_________________
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 Dec 23, 2012 8:49 am    Post subject: Reply with quote

ms = createMemScan()
memscan_firstScan(ms, soExactValue, vtString, "", "Orrin", "", 0, 0xffffffffffffffff, fsmNotAligned, "", true, false, true, true);--changed the last four options after re-reading and analyzing what params mean
fl = createFoundList(ms);
foundlist_getCount(fl);
--foundlist_getAddress(fl, "");--deleted this line didn't appear to be necessary
for x = 0, foundlist_getCount(fl)-1 do
if readString(foundlist_getAddress(fl, x) + 0x22c9e, 4) == "Tiva" then--changed as your suggestion
byteoffset = foundlist_getAddress(fl, x);
--Should be the address to recalculate table addresses
end;
end;
addresslist = getAddressList();
memrec1 = addresslist_getMemoryRecordByDescription(addresslist, "Orrin");
orrinaddress = memoryrecord_getAddress(memrec1);
for x = 0, addresslist_getCount(addresslist)-1 do
memrec2 = addresslist_getMemoryRecordByID(addresslist, x);
if "0x" .. byteoffset >= "0x" .. orrinaddress then
memoryrecord_setAddress(memrec2, "0x".. memoryrecord_getAddress(memrec2) - "0x" .. byteoffset);
else
memoryrecord_setAddress(memrec2, "0x".. memoryrecord_getAddress(memrec2) + "0x" .. byteoffset);
end;
end;
Made indicated changes stepwise and as a group with the same error message "attempt to concatenate global 'byteoffset' (a nil value)"
In the Lua script window there are green bars left of line 2 and lines 5-8, if that helps.
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sun Dec 23, 2012 8:54 am    Post subject: Reply with quote

foundlist_getAddress(fl, x) returns a string using ce's addressing. (Hexadecimal without 0x). Add 0x in front of it for lua to recognize it as a integer instead of string
_________________
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 Dec 23, 2012 12:34 pm    Post subject: Reply with quote

In one of my attempts this morning, although not posted, was to change
if readString(foundlist_getAddress(fl, x) + 0x22c9e, 4) == "Tiva" then

to

if readString("0x" .. foundlist_getAddress(fl, x) + 0x22c9e, 4) == "Tiva" then

On the thought that the two may not be the same thing, but still got the error message concerning concatenating with a nil.
I've tried many combinations attemting to find a solution, but not documented them.

To make sure I understand what the statement does
foundlist_getAddress (fl, x) should return something resembling "0125D60F" ?
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sun Dec 23, 2012 1:20 pm    Post subject: Reply with quote

yes, but to make it deal with the "+ 0x22c9e" it needs to be formatted as 0x0125d60f (else it with never find it, causing the var to be nil)

anyhow, split up the script into smaller chunks and run that. Add extra debugprints and asserts

_________________
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 Dec 23, 2012 3:33 pm    Post subject: Reply with quote

ms = createMemScan()
memscan_firstScan(ms, soExactValue, vtString, "", "Orrin", "", 0, 0xffffffffffffffff, fsmNotAligned, "", true, false, true, true);
fl = createFoundList(ms);
foundlist_getCount(fl);
--foundlist_getAddress(fl, "");
for x = 0, foundlist_getCount(fl)-1 do
--if readString("0x" .. foundlist_getAddress(fl, x) + 0x22c9e, 4) == "Tiva" then
memrec1 = foundlist_getAddress(fl, x);
memrec1 = "0x" .. memrec1;
if readString(memrec1 + 0x22c9e, 4) == "Tiva" then
byteoffset = memrec1;
--byteoffset = foundlist_getAddress(fl, x);
--Should be the address to recalculate table addresses
end;
debugger_onBreakpoint();
end;
addresslist = getAddressList();
memrec1 = addresslist_getMemoryRecordByDescription(addresslist, "Orrin");
orrinaddress = memoryrecord_getAddress(memrec1);
orrinaddress = "0x" .. orrinaddress;
for x = 0, addresslist_getCount(addresslist)-1 do
memrec2 = addresslist_getMemoryRecordByID(addresslist, x);
if byteoffset >= orrinaddress then
memoryrecord_setAddress(memrec2, memoryrecord_getAddress(memrec2) - byteoffset);
else
memoryrecord_setAddress(memrec2, memoryrecord_getAddress(memrec2) + byteoffset);
end;
end;

function debugger_onBreakpoint()
end;

I would love to do some debug prints, but again lost in the language.
byteoffset is still a nil
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Tue Dec 25, 2012 6:04 am    Post subject: Reply with quote

Use print(string) for debug output

Also i didn't notice at first but you removed the foundlist_initialize(foundlist); line. You will need that.
And before you initialize the list you must first wait for the memscan object to finish scanning.

_________________
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 Dec 30, 2012 11:07 am    Post subject: Reply with quote

ms = createMemScan()
memscan_firstScan(ms, soExactValue, vtString, "", "Orrin", "", 0, 0xffffffffffffffff, fsmNotAligned, "", true, false, true, true);
memscan_waitTillDone(ms);
fl = createFoundList(ms);
foundlist_initialize(fl);
foundlist_getCount(fl);
print(foundlist_getCount(fl));
--Zero output from print statement
for x = 0, foundlist_getCount(fl)-1 do
--if readString("0x" .. foundlist_getAddress(fl, x) + 0x22c9e, 4) == "Tiva" then
memrec1 = foundlist_getAddress(fl, x);
print(memrec1);
memrec1 = "0x" .. memrec1;
if readString(memrec1 + 0x22c9e, 4) == "Tiva" then
byteoffset = memrec1;
--byteoffset = foundlist_getAddress(fl, x);
--Should be the address to recalculate table addresses
end;
end;
addresslist = getAddressList();
memrec1 = addresslist_getMemoryRecordByDescription(addresslist, "Orrin");
orrinaddress = memoryrecord_getAddress(memrec1);
orrinaddress = "0x" .. orrinaddress;
for x = 0, addresslist_getCount(addresslist)-1 do
memrec2 = addresslist_getMemoryRecordByID(addresslist, x);
if byteoffset >= orrinaddress then
memoryrecord_setAddress(memrec2, memoryrecord_getAddress(memrec2) - byteoffset);
else
memoryrecord_setAddress(memrec2, memoryrecord_getAddress(memrec2) + byteoffset);
end;
end;

Ok, I didn't know we had to wait so I added the line, I hope in the correct spot along with foundlist_initialiaze(fl); (again I hope in the right spot).

With the print(foundlist_getCount(fl)); output was 0, followed by attempting to compare a nil with a string. So if my coding down to the print statement, excluding the memscan_firstScan(.....) is correct, then it appears that the memscan statement is incorrect.
I was unable to respond for a week as the web site was banned from the service provided. Could you send a PM with a email address to prevent the delay from happening again?
Thanks

Edit: Changed memscam line to memscan_firstScan(ms, soExactValue, vtString, "", "Orrin", "", 0, 0xffffffffffffffff, "", fsmNotAligned, "", false, false, true, true);--Added an AOBScan param(""), change isHexadecimalInput to false
No change in the reslults: Zero count and attempting to compare nil with string


Last edited by bknight2602 on Sun Dec 30, 2012 11:54 am; edited 1 time in total
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sun Dec 30, 2012 11:44 am    Post subject: Reply with quote

try this:
Code:

memscan_firstScan(ms, soExactValue, vtString, rtRounded, "Orrin", "", 0, 0xffffffffffffffff, "*X*C*W", fsmNotAligned, "", false, false, false, true);


and if it's an unicode string try
Code:

memscan_firstScan(ms, soExactValue, vtString, rtRounded, "Orrin", "", 0, 0xffffffffffffffff, "*X*C*W", fsmNotAligned, "", false, false, true, true);

_________________
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 Dec 30, 2012 12:27 pm    Post subject: Reply with quote

First sign of progress, thanks
ms = createMemScan()
memscan_firstScan(ms, soExactValue, vtString, rtRounded, "Orrin", "", 0, 0xffffffffffffffff, "*X*C*W", fsmNotAligned, "", false, false, false, true);
--memscan_firstScan(ms, soExactValue, vtString, rtRounded, "Orrin", "", 0, 0xffffffffffffffff, "*X*C*W", fsmNotAligned, "", false, false, true, true);
--memscan_firstScan(ms, soExactValue, vtString, "", "Orrin", "", 0, 0xffffffffffffffff, "", fsmNotAligned, "", false, false, true, true);
memscan_waitTillDone(ms);
fl = createFoundList(ms);
foundlist_initialize(fl);
foundlist_getCount(fl);
print(foundlist_getCount(fl));
for x = 0, foundlist_getCount(fl)-1 do
--if readString("0x" .. foundlist_getAddress(fl, x) + 0x22c9e, 4) == "Tiva" then
memrec1 = foundlist_getAddress(fl, x);
print(memrec1);
memrec1 = "0x" .. memrec1;
print(memrec1);
if readString(memrec1 + 0x22c9e, 4) == "Tiva" then
byteoffset = memrec1;
print(byteoffset);
--byteoffset = foundlist_getAddress(fl, x);
--Should be the address to recalculate table addresses
end;
end;

Not sure why but the first option worked, as I would have thought it would be a unicode, with output of:

4
011BD058
0x011BD058
0125D60F --The correct address
0x0125D60F --Added the 0x
01342C60
0x01342C60
03AA8531
0x03AA8531

byteoffset never printed so the readstring statement is incorrect as entered

Tiva exists at:
012802AD-This is the correct addres
012C0590
013497B3

What does the *X*C*W represent?

Edit:
Tinkering with partial success, I tried this:
ms = createMemScan()
memscan_firstScan(ms, soExactValue, vtString, rtRounded, "Orrin", "", 0, 0xffffffffffffffff, "*X*C*W", fsmNotAligned, "", false, false, false, true);
--memscan_firstScan(ms, soExactValue, vtString, rtRounded, "Orrin", "", 0, 0xffffffffffffffff, "*X*C*W", fsmNotAligned, "", false, false, true, true);
--The above did not work
--memscan_firstScan(ms, soExactValue, vtString, "", "Orrin", "", 0, 0xffffffffffffffff, "", fsmNotAligned, "", false, false, true, true);
--The above did not work
memscan_waitTillDone(ms);
fl = createFoundList(ms);
foundlist_initialize(fl);
foundlist_getCount(fl);
--print(foundlist_getCount(fl));
--foundlist_getAddress(fl, "");
for x = 0, foundlist_getCount(fl)-1 do
--if readString("0x" .. foundlist_getAddress(fl, x) + 0x22c9e, 4) == "Tiva" then
memrec1 = foundlist_getAddress(fl, x);
--print(memrec1);
memrec1 = "0x" .. memrec1;
print(memrec1);
tivaaddress = memrec1 + 0x22c9e;--added these two lines
print(tivaaddress);
if readString(memrec1 + 0x22c9e, 4) == "Tiva" then
byteoffset = memrec1;
print(byteoffset);
--byteoffset = foundlist_getAddress(fl, x);
--Should be the address to recalculate table addresses
end;
end;

Output of Orrin addresses plus 0x22c9e value

0x011BD058
18742518
0x0125D60F--Correct address corresponding to Tiva at 012802AD
19399341--Totally don't understand how this was calculated
0x01342C60
20338942
0x03AA8531
61649359
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sun Dec 30, 2012 2:57 pm    Post subject: Reply with quote

19399341 is the decimal representation of 012802ad

this code will convert a decimal value to a hexadecimal string
Code:

s='0x'..string.format('%x', value)

_________________
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 Dec 30, 2012 7:53 pm    Post subject: Reply with quote

ms = createMemScan()
memscan_firstScan(ms, soExactValue, vtString, rtRounded, "Orrin", "", 0, 0xffffffffffffffff, "*X*C*W", fsmNotAligned, "", false, false, false, true);
memscan_waitTillDone(ms);
fl = createFoundList(ms);
foundlist_initialize(fl);
foundlist_getCount(fl);
for x = 0, foundlist_getCount(fl)-1 do
then
memrec1 = foundlist_getAddress(fl, x);
print(memrec1);--Output 0125D60F
memrec1 = "0x" .. memrec1;
print(memrec1);Output 0x0125D60F
tivaaddress = memrec1 + 0x22c9e;
memrec1 = string.format('%x', tivaaddress);
print(memrec1);--Output 12802ad
if readString(memrec1, 5) == "Tiva" then
byteoffset = "0x" .. memrec1;
print(byteoffset);--Output 0x12802ad
--Should be the address to recalculate table addresses
end;
--debugger_onBreakpoint();
end;
addresslist = getAddressList();
memrec2 = addresslist_getMemoryRecordByDescription(addresslist, "Orrin");--Orrin is the 58th entry in table
print(memrec2);--Output 031A5C78
memrec3 = memoryrecord_getAddress(memrec2);
print(memrec3);==Output 19256847
orrinaddress = memrec3;
orrinaddress = string.format('%x', orrinaddress);
orrinaddress = "0x" .. orrinaddress;
for x = 0, addresslist_getCount(addresslist)-1 do
memrec2 = addresslist_getMemoryRecordByID(addresslist, x);
if byteoffset > orrinaddress then
memoryrecord_setAddress(memrec2, memoryrecord_getAddress(memrec2) - byteoffset);
elseif byteoffset < orrinaddress then
memoryrecord_setAddress(memrec2, memoryrecord_getAddress(memrec2) + byteoffset);
else
end;
end;
--function debugger_onBreakpoint()
--end;

CE has become unresponsive. If it ever opens I'm going to have to go back to the drawing board.
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 Dec 31, 2012 7:11 pm    Post subject: Reply with quote

It took 2.5 hours to get out of the mess, all the table address were screwed up, but I had a recent copy. Not too bad to get going again.

REALLY CLOSE
ms = createMemScan()
memscan_firstScan(ms, soExactValue, vtString, rtRounded, "Orrin", "", 0, 0xffffffffffffffff, "*X*C*W", fsmNotAligned, "", false, false, false, true);
--memscan_firstScan(ms, soExactValue, vtString, rtRounded, "Orrin", "", 0, 0xffffffffffffffff, "*X*C*W", fsmNotAligned, "", false, false, true, true);
--The above did not work
--memscan_firstScan(ms, soExactValue, vtString, "", "Orrin", "", 0, 0xffffffffffffffff, "", fsmNotAligned, "", false, false, true, true);
--The above did not work
memscan_waitTillDone(ms);
fl = createFoundList(ms);
foundlist_initialize(fl);
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);
memrec2 = "0x" .. memrec1;
tivaaddress = memrec2 + 0x22c9e;--Items are in the number format of the hex summation
tivaaddress = string.format('%x', tivaaddress);--Items in number format converted to hex format without 0x
if readString(tivaaddress, 5) == "Tiva" then
byteoffset = memrec1;--byteoffset is in the hex format (0125D60F) without 0x, need code to convert back to number
print("byteoffset", byteoffset);--Output 0125D60F
end;
--debugger_onBreakpoint();
end;
addresslist = getAddressList();
memrec2 = addresslist_getMemoryRecordByDescription(addresslist, "Orrin");
orrinaddress = memoryrecord_getAddress(memrec2);--Item in num format
print("orrinaddress", orrinaddress);--15062542
----for x = 0, 1 do--addresslist_getCount(addresslist)-1 do
----memrec2 = addresslist_getMemoryRecordByID(addresslist, x);
print("byteoffset orrinaddress difference",byteoffset - orrinaddress);--Won't work as byteoffset is a string, need code to convert to number
----if byteoffset > orrinaddress then
----memoryrecord_setAddress(memrec2, memoryrecord_getAddress(memrec2) + byteoffset - orrinaddress);
----elseif byteoffset < orrinaddress then
----memoryrecord_setAddress(memrec2, memoryrecord_getAddress(memrec2) - byteoffset + orrinaddress);
----else
----end;
----end;

--function debugger_onBreakpoint()
--end;
Two helps needed:
1. Code to convert string 0125D60F to number
2. How can a break point be coded to "pause" at the end of each of the for loop. That way I could print the old address and new address to see if the procedure applied is correct.
Back to top
View user's profile Send private message Yahoo 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