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 


Using Lua engine to scan for a particular value?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
DontWannaBeASkid
Newbie cheater
Reputation: 0

Joined: 01 Mar 2014
Posts: 13

PostPosted: Sun Mar 02, 2014 12:30 pm    Post subject: Using Lua engine to scan for a particular value? Reply with quote

Hi.
To get me started with CE Lua I wanted to try and perform something with a script that I normally do with the Scan feature.

In a game I play, I perform a scan for a float value with the value of 1000000. I then change all the results to zero.
I tried to build a script to do this, however it isn't returning any values. Can someone tell me what's wrong?

local scan = createMemScan(true)
memscan_returnOnlyOneResult(scan,true)
memscan_firstScan(scan,soExactValue,vtSingle,rtRounded,"1000000",nil,0,0xffffffffffffffff,"",fsmNotAligned,nil,false,false,false,false)
memscan_waitTillDone(scan)
local result=memscan_getOnlyResult(scan)
if result==nil then print 'LOL' else print 'WE GOT IT' end

(The output is LOL)
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Sun Mar 02, 2014 1:06 pm    Post subject: Reply with quote

Took a test program, wrote 1000000 as float somewhere, and ran your script. The result was "WE GOT IT".

Did you forget to attach CE to your target?

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
DontWannaBeASkid
Newbie cheater
Reputation: 0

Joined: 01 Mar 2014
Posts: 13

PostPosted: Sun Mar 02, 2014 3:35 pm    Post subject: RE: Reply with quote

Nvm, I modified it and it now works - you were right about me not attaching it.

Thanks for your help.

How would I program CE to change all the values to 0?
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Sun Mar 02, 2014 6:01 pm    Post subject: Reply with quote

Code:
--Scan
local scan = createMemScan(true);
scan.setOnlyOneResult(false);
scan.firstScan(soExactValue,vtSingle,rtRounded,"123456",nil,0,0xffffffffffffffff,"",fsmNotAligned,nil,false,false,false,false);
scan.waitTillDone();

--Fetch result
local FoundList=createFoundList(scan);
FoundList.initialize();

--Overwite
for i=0,FoundList.Count-1 do
  --print(FoundList.Address[i]);
  writeFloat(FoundList.Address[i],0.0);
end

--Cleanup
FoundList.deinitialize();
FoundList.destroy();
FoundList=nil;
scan.destroy();
scan=nil;


BTW: the documentation for all CE lua function can be found in the main.lua contained in your cheat engine directory.

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
DontWannaBeASkid
Newbie cheater
Reputation: 0

Joined: 01 Mar 2014
Posts: 13

PostPosted: Mon Mar 03, 2014 3:28 am    Post subject: Reply with quote

Thanks, it did work.

However when I use the script (even if I don't put in the clean up part) the game crashes after a couple of seconds, I tried doing it manually and it didn't cause it to crash. Do I need to put in some wait() s?
--Scan
local scan = createMemScan(true);
scan.setOnlyOneResult(false);
scan.firstScan(soExactValue,vtSingle,rtRounded,"1000000",nil,0,0xffffffffffffffff,"",fsmNotAligned,nil,false,false,false,false);
scan.waitTillDone();

--Fetch result
local FoundList=createFoundList(scan);
FoundList.initialize();

--Overwite
for i=0,FoundList.Count-1 do
print(FoundList.Address[i]);
writeFloat(FoundList.Address[i],0.0);
end

--Cleanup
FoundList.deinitialize();
FoundList.destroy();
FoundList=nil;
scan.destroy();
scan=nil;
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Mon Mar 03, 2014 7:00 am    Post subject: Reply with quote

DontWannaBeASkid wrote:
However when I use the script (even if I don't put in the clean up part) the game crashes after a couple of seconds, I tried doing it manually and it didn't cause it to crash. Do I need to put in some wait() s?
No. What did you intend to do with some delays?
Try:
scan.firstScan(soExactValue,vtSingle,rtRounded,"1000000",nil,0,0xffffffffffffffff,"+W-C",fsmNotAligned,nil,false,false,false,false);
instead of:
scan.firstScan(soExactValue,vtSingle,rtRounded,"1000000",nil,0,0xffffffffffffffff,"",fsmNotAligned,nil,false,false,false,false);

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
DontWannaBeASkid
Newbie cheater
Reputation: 0

Joined: 01 Mar 2014
Posts: 13

PostPosted: Mon Mar 03, 2014 9:29 am    Post subject: Reply with quote

Thanks, that did make the difference. I appreciate your help.
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 Lua Scripting 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 can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites