Typically: "How do I... ", "How can I... " questions
coppelia
Site Admin
Posts: 10504 Joined: 14 Dec 2012, 00:25
Post
by coppelia » 05 Sep 2024, 09:22
Yes, you can easily control which script and when will execute. You however need to distinguish between
threaded and non-threaded scripts :
Non-threaded scripts follow a precise execution order
Threaded script actually also follow above script execution order for resuming a thread. The simplest way to start/stop execution of a specific part of code would be doing:
Code: Select all
function sysCall_thread()
sim.setStepping(true)
sim.setInt32Signal('script1 ready', 0)
sim.waitForSignal('script0 ready')
... execute some code here
sim.setInt32Signal('script1 ready', 1)
sim.waitForSignal('script0 ready')
sim.setInt32Signal('script1 ready', 0)
... execute some code here
sim.setInt32Signal('script1 ready', 1)
sim.waitForSignal('script0 ready')
...
end
Cheers
Jonatas Teixeira
Posts: 17 Joined: 13 Oct 2023, 18:04
Post
by Jonatas Teixeira » 05 Sep 2024, 22:13
I don't know exactly what I did wrong but I used the code:
Code: Select all
while true do
print("coroutineMain, NA")
sim.setInt32Signal("NAdetect",0)
sim.waitForSignal("NAdetect")
print("coroutineMain after wait, NAdet="..sim.getInt32Signal("NAdetect"))
...
and got:
Code: Select all
coroutineMain, NA
coroutineMain after wait, NAdet=0
I read the function documentation and found that
The function only returns when the signal is present (defined)
Does it mean it won't wait if it's 0 (defined)?
Did I miss anything?
coppelia
Site Admin
Posts: 10504 Joined: 14 Dec 2012, 00:25
Post
by coppelia » 06 Sep 2024, 06:20
If an int signal is 0, it is defined. You need to clear it with sim.clearInt32Signal
Cheers