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 


stringlist_getString()

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
Doctor Death
Cheater
Reputation: 1

Joined: 26 Apr 2014
Posts: 42
Location: Breaking Code

PostPosted: Wed Feb 25, 2015 8:29 am    Post subject: stringlist_getString() Reply with quote

Long story short..

There's a game. And it has items. There's an item hack, where to use it, you have to find an aob, replace all the results' bytes with "02" (nop in as3)

But when you search for the aob, there are multiple results, and every time you restart the game, each one is different, but only one is truly for the items...

I was looking at some old threads, and discovered how to (by using Lua) choose whatever AOBScan result you want. Like, in a list. Starting at 0=1, 1=2, and so on.

It was using this function: stringlist_getString()

Since I already know how to use lua very well, I made this, which worked like a charm:

Code:

local results = AOBScan([[d0 4e da 02 00]]) -- Look for all the results
for i=0, 7 do -- Eight times, since there are 8 results.
   local address = stringlist_getString(results,i) -- one of the results
   local script = address..[[:
      db 02 02 02 02 02 // The nop (in as3) so my items don't run out. :)
   ]]
   autoAssemble(script) -- Run this script for each and every result.
end


But what is stringlist_getString()? What does that function do?
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 146

Joined: 07 Nov 2008
Posts: 4135
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Wed Feb 25, 2015 11:48 am    Post subject: Reply with quote

AOBScan function, in Lua, is a native C function written by Dark Byte, and it returns results as stringlist object - link.
In Lua terms, this object is a "full userdata" - link.
It is a raw memory area with no predefined operations in Lua. For such data, we have to register C functions (native). DarkByte already made it for you.


In CE6.2 there are many registered functions and "abstract" classes - just read main.lua file from CE6.2 directory.

CE6.3 comes with redesigned lua class system. We have metatables and "real" classes. Objects have properties and methods. Again, read updated main.lua documentation file.

Instead of this:
Code:
local address = stringlist_getString(results,i)


we just use this:
Code:
local address = results.String[i]


or this
Code:
local address = results[i]



or this
Code:
local address = results.getString(i)




The script you are using is not good.
Code:
local results = AOBScan([[d0 4e da 02 00]]) -- Look for all the results
for i=0, 7 do -- Eight times, since there are 8 results.
   local address = stringlist_getString(results,i) -- one of the results
   local script = address..[[:
      db 02 02 02 02 02 // The nop (in as3) so my items don't run out. :)
   ]]
   autoAssemble(script) -- Run this script for each and every result.
end

You didn't handle errors and list size. You can get "Error:List index out of bounds" messages.



The fixed and modern version will be:
Code:
local results = AOBScan([[d0 4e da 02 00]])
local count = results.Count
if count > 8 then count = 8 end -- only first 8 results

for i=0, count-1 do
   local address = results[i] -- i'th result
   local script = address..[[:
      db 02 02 02 02 02 // The nop (in as3) so my items don't run out. :)
   ]]
   autoAssemble(script) -- Run this script for each and every result.
end




If you already know that 4th result is the correct one:
Code:
local results = AOBScan([[d0 4e da 02 00]])
if results.Count >= 4 then
   local address = results[3]
   local script = address..[[:
      db 02 02 02 02 02
   ]]
   autoAssemble(script)
end






By the way, you can use code below, instead of autoAssemble():
Code:
writeBytes(address, 2,2,2,2,2)

_________________
Back to top
View user's profile Send private message MSN Messenger
Doctor Death
Cheater
Reputation: 1

Joined: 26 Apr 2014
Posts: 42
Location: Breaking Code

PostPosted: Wed Feb 25, 2015 4:43 pm    Post subject: Reply with quote

mgr.inz.Player wrote:
AOBScan function, in Lua, is a native C function written by Dark Byte, and it returns results as stringlist object - link.
In Lua terms, this object is a "full userdata" - link.
It is a raw memory area with no predefined operations in Lua. For such data, we have to register C functions (native). DarkByte already made it for you.


In CE6.2 there are many registered functions and "abstract" classes - just read main.lua file from CE6.2 directory.

CE6.3 comes with redesigned lua class system. We have metatables and "real" classes. Objects have properties and methods. Again, read updated main.lua documentation file.

Instead of this:
Code:
local address = stringlist_getString(results,i)


we just use this:
Code:
local address = results.String[i]


or this
Code:
local address = results[i]



or this
Code:
local address = results.getString(i)




The script you are using is not good.
Code:
local results = AOBScan([[d0 4e da 02 00]]) -- Look for all the results
for i=0, 7 do -- Eight times, since there are 8 results.
   local address = stringlist_getString(results,i) -- one of the results
   local script = address..[[:
      db 02 02 02 02 02 // The nop (in as3) so my items don't run out. :)
   ]]
   autoAssemble(script) -- Run this script for each and every result.
end

You didn't handle errors and list size. You can get "Error:List index out of bounds" messages.



The fixed and modern version will be:
Code:
local results = AOBScan([[d0 4e da 02 00]])
local count = results.Count
if count > 8 then count = 8 end -- only first 8 results

for i=0, count-1 do
   local address = results[i] -- i'th result
   local script = address..[[:
      db 02 02 02 02 02 // The nop (in as3) so my items don't run out. :)
   ]]
   autoAssemble(script) -- Run this script for each and every result.
end




If you already know that 4th result is the correct one:
Code:
local results = AOBScan([[d0 4e da 02 00]])
if results.Count >= 4 then
   local address = results[3]
   local script = address..[[:
      db 02 02 02 02 02
   ]]
   autoAssemble(script)
end






By the way, you can use code below, instead of autoAssemble():
Code:
writeBytes(address, 2,2,2,2,2)


ah

I see.

I was actually thinking of using a variable of the number of results. xd

Thanks, and I'll read up some more stuff on CE's Lua too.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials All times are GMT - 6 Hours
Page 1 of 1

 
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 cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites