How to avoid a mimoLive script from running until another script is done?

For this, you have to separate your scripts into functions. With a code like this, every necessary script can announce that it’s running next. Other scripts are checking if they are allowed to run. As long as the status is “pending”, the script is waiting until the status changes. First come, first serve:

// sleep(0.5)
ifLayerIsOn($triggersPendingYes))
	// loop a bit
	sleep($pendingTime)
	
else 
	// set triggersPending to Yes
	layerOn($triggersPendingYes)

	///////////////////////////
	// code to process:
	///////////////////////////
	// PLACE YOUR INDIVIDUAL SCRIPT HERE!

	// end (goto DONE)
	layerOn($preTriggersDONE)

endif

This technique is very handy, especially when you use dynamic - script based - video- and/or audio-switching. With it, you’re able to avoid conflicts between scripts.

A Demo:
At the LayerSets, you can press the buttons in any sequence you want. When the scripts start exactly the same time, both scripts are processed, so you should add extra time at the beginning of the “secondary” script (At the example, the first line is commented out.), or take advantage out of this phenomenon. :D.
https://drive.google.com/file/d/1fZT7UljeooeQrMYJsAv9j72oQDBeuTCW/view?usp=sharing

Notice:
The “Done”-Variants are there to set triggersPending back to “no”.

At the “globals”-Script all configuration is done:

setGlobal($triggersPendingNo, "/api/v1/documents/33665208/layers/CAC44B16-1352-4868-A613-BF2D1DC699D7/variants/8EFE84CB-FF3F-4569-9DE1-7FF6E361D107")
setGlobal($triggersPendingYes, "/api/v1/documents/33665208/layers/CAC44B16-1352-4868-A613-BF2D1DC699D7/variants/245866CD-F2FA-4C3D-96B8-C44245EA1B61")
setGlobal($postTriggersDONE, "/api/v1/documents/33665208/layers/0557AB0E-CF4F-4C32-B088-16864D023D90/variants/468689C0-63FF-4CDC-BFC0-7A0432597C65")
setGlobal($preTriggersDONE, "/api/v1/documents/33665208/layers/755D7957-039D-4B27-B07B-56F7D33569F2/variants/CC30EA0D-EDC0-401D-8CD1-78E506C36162")
setGlobal($pendingTime, 2)

By the way:
With scripts like this, you’re able to manage complex to-do’s way more easy. You need more “Trigger”-Layers? Feel free to add some. At the globals, you have to set own API-Endpoints and variables. Afterwards you have to modify the basic script. Just change this segment from

// end (goto DONE)
    	layerOn($preTriggersDONE)

to

// end (goto DONE)
    	layerOn($yourVariable4DONE)