View previous topic :: View next topic |
Author |
Message |
Kamd Cheater Reputation: 1
Joined: 02 May 2018 Posts: 28
|
Posted: Fri Dec 14, 2018 9:18 pm Post subject: Use MemScan without callback function (return num of result) |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Sat Dec 15, 2018 2:11 am Post subject: |
|
|
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 |
|
|
Kamd Cheater Reputation: 1
Joined: 02 May 2018 Posts: 28
|
Posted: Sat Dec 15, 2018 9:52 pm Post subject: |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Sun Dec 16, 2018 1:50 am Post subject: |
|
|
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 |
|
|
Kamd Cheater Reputation: 1
Joined: 02 May 2018 Posts: 28
|
Posted: Sun Dec 16, 2018 7:29 pm Post subject: |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Mon Dec 17, 2018 1:23 am Post subject: |
|
|
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 |
|
|
|