MV Custom Wait in Script

Hello,
As someone with (a little) Javascript experience, I'd like some help with understanding how I can implement a custom "wait" function in an event script for MV. Essentially, it would be very similar to what HimeWorks has implemented here (all credit to them) - which halts event processing until a given condition is met.
I have done my best to look for answers for both MV and Javascript generally, but I can't find anything which is compatible or feasible. I don't want to have to do a loop which checks every few seconds, so if anyone has a better answer, please tell me! Thank you!
you could event it with an loop-repeat depending what you need
or through a switch and common event.

control variable x = 0 (as it can start from 0 to count upwards, 100 or more for down)
loop
wait 1 (1 frame for counting, use 60 for seconds)
variable x += 1
if: variable x == 60 (60 seconds)
text: done
breakloop
end
repeat above

wait is 60
for counting down, you can do variable x -= 1

and wait x seconds, I think you cannot move.

another way is in a common event, but without the loop, but parallel by switch
that is turned ON or OFF when done (you can figure this one out else I give
an example on this part.

Original thread: https://forums.rpgmakerweb.com/threads/custom-wait-in-script.171194/