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 


execute asynchronous

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
FauDrei
Advanced Cheater
Reputation: 4

Joined: 20 Nov 2013
Posts: 69
Location: bachLai

PostPosted: Fri Mar 23, 2018 6:20 am    Post subject: execute asynchronous Reply with quote

Regards.

How does "execute asynchronous" differ to standard AA script enabling and disabling?

Does it have any effect on enabling/disabling nested scripts (f.e. nested scripts are executed after execution of parent script and subsequently nested scripts are disabled before disabling parent script)?

Or it does something completely different?

Thanks in advance for your answers.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4289

PostPosted: Fri Mar 23, 2018 9:02 am    Post subject: Reply with quote

The main thread usually handles AA scripts and Lua. If something in a script blocks the main thread, CE can't do anything else and it becomes unresponsive until the script finishes.

Executing a script asynchronously will create a thread to execute it. This won't block the main thread, but it also means you can't access GUI objects (only the main thread can).

If an AA script is set to activate/deactivate its children when it is activated/deactivated, the parent script is synchronized before all child scripts (for both cases) regardless if any particular script is executing asynchronously.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
FauDrei
Advanced Cheater
Reputation: 4

Joined: 20 Nov 2013
Posts: 69
Location: bachLai

PostPosted: Fri Mar 23, 2018 11:08 am    Post subject: Reply with quote

Thanks ParkourPenguin.

...and what about activating/deactivating nested AA scripts that are not set to activate/deactivate its children? Is there a deterministic sequence for their execution?

I am asking that because I sometimes use a single hotkey to activate/deactivate many (also nested) scripts and would like to know the activation/deactivation sequence as well as if there is a way to control that sequence.

Thanks again.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4289

PostPosted: Fri Mar 23, 2018 11:45 am    Post subject: Reply with quote

FauDrei wrote:
...and what about activating/deactivating nested AA scripts that are not set to activate/deactivate its children?

If you are activating / deactivating each memory record, you're responsible for sequencing.

With regards to separate hotkeys, I don't know if there are any guarantees in which order CE checks them. I guess you could look for a pattern and hope it doesn't change in future versions of CE, but you'd be better off controlling it yourself.

e.g.:
Code:
function activateAll(memrec)
  memrec.Active = true
  for i = 0, memrec.Count - 1 do
    activateAll(memrec.Child[i])
  end
end

function deactivateAll(memrec)
  for i = memrec.Count - 1, 0, -1 do
    deactivateAll(memrec.Child[i])
  end
  memrec.Active = false
end

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
FauDrei
Advanced Cheater
Reputation: 4

Joined: 20 Nov 2013
Posts: 69
Location: bachLai

PostPosted: Fri Mar 23, 2018 1:11 pm    Post subject: Reply with quote

Thanks again.

...but, again, more questions for me...

How do I refer to a specific AA script from LUA?

For example: I have AA scripts named a, b and c with their appropriate child scripts named aa, ab, ac, ba, bb, bc, ca, cb and cc. What would be LUA script that would activate script b and then b's child scripts bc and then ba?

Also, how do you assign LUA function to a hotkey?

Sorry for so many questions, and thanks for all your answers.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4289

PostPosted: Fri Mar 23, 2018 2:47 pm    Post subject: Reply with quote

Using the two previous functions:
Code:
local al = getAddressList()
local memrec = al.getMemoryRecordByDescription('a')
local enabled = false

if my_special_hotkey then my_special_hotkey.destroy(); my_special_hotkey = nil end

my_special_hotkey = createHotkey(function(hk)
  if enabled then
    deactivateAll(memrec)
  else
    activateAll(memrec)
  end
  enabled = not enabled
end, VK_CONTROL, VK_Q)


Most of CE's Lua API is documented in celua.txt.
Code:
MemoryRecord Class:
properties
  ...
  Count: Number of children
  Child[index] : Array to access the child records

...
Addresslist Class:
...
methods
  getMemoryRecord(index)
  getMemoryRecordByDescription(description)
  getMemoryRecordByID(ID)


Many examples can be found by searching for them.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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 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