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 


Use MemScan without callback function (return num of result)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Kamd
Cheater
Reputation: 1

Joined: 02 May 2018
Posts: 28

PostPosted: Fri Dec 14, 2018 9:18 pm    Post subject: Use MemScan without callback function (return num of result) Reply with quote

I am using the MemScan functionality in CE Lua to scan and replace strings, and once done to return the number of results that were found/changed.

It does not work if I try return the number of results inside the onScanDone callback function.

So my question is, how can I not use this callback function so I can return the number of results from the executed function.

Here is my relevant code:
Code:

function strScanReplace(find, replace)
    ms = createMemScan()

    ms.firstScan(...)

    ms.onScanDone = (...) -- Can't use callback to return?
    --ms.waitUntilDone() ?
    f = createFoundList(ms)
    f.initialize()

    -- .. do my stuff ..

    return f.Count
end

replaced = strScanReplace("hey", "bye")
print("You have replaced " .. replaced .. " results")
-- e.g: You have replaced 5 results
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sat Dec 15, 2018 2:11 am    Post subject: Reply with quote

in onScanDone you still need to create a foundlist and use that to get the count
_________________
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
Kamd
Cheater
Reputation: 1

Joined: 02 May 2018
Posts: 28

PostPosted: Sat Dec 15, 2018 9:52 pm    Post subject: Reply with quote

Dark Byte wrote:
in onScanDone you still need to create a foundlist and use that to get the count


I understand this, it's what I currently do. It's just a bad workflow for me in using callback functions.

So I was wondering if it is possible to not use callback, and wait in the initial function until the scan is done. I guess this isn't possible.

Thanks anyways.

Maybe it's possible to set variable to true in the callback function to indicate it's ready in the main function, but it's probably even worse to keep checking variable until it's true.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sun Dec 16, 2018 1:50 am    Post subject: Reply with quote

have you looked into what that commented out line waitUntilDone does ?
_________________
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
Kamd
Cheater
Reputation: 1

Joined: 02 May 2018
Posts: 28

PostPosted: Sun Dec 16, 2018 7:29 pm    Post subject: Reply with quote

Dark Byte wrote:
have you looked into what that commented out line waitUntilDone does ?


Just an example I wrote to try get my point across better, unfortunately the function does not exist.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Mon Dec 17, 2018 1:23 am    Post subject: Reply with quote

try ms.waitTillDone()

(read celua.txt)

_________________
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
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