Terry, I think you are missing the point. G code is NOT a programming language in the classical sense. It is a command language. It has no logic statements without the macro B stuff. No way to control the flow at all sans the simple sub routine mechanism at all. For example, what is the G code to test that machine movement has been completed? What in G code notifies the operator of the machine that the G code is complete? I mean standard G code. Not a scripted macro. M00? M01? What action/event is taken by the G code if "G00 X0Y0" is executed and then completed? Nothing. The machine executed the code and then just sits there like a bump on a log waiting for the operator to do something else.
Macro B is not another language. It is an extension of the G code command set. It executes in the same context as the regular G code. Therefore it is an apples and oranges comparison.
Waiting on an event in a PLC with a loop is controlling program flow. It is a LESS efficient way of doing so! Ladder with VB is an extension just like Macro B is an extension to G code. It operates in the same "program" context. It is the same interpreter on the same device. So how would you take TWO PLCs and make them work with each other? That is a better example. You will HAVE to use flow control mechanisms to prevent a race condition in one or the other PLC. Because you are now executing code in two different environments/devices/contexts. Is it a kludge? Certainly not.
With that HUGE thing said, there is no possible way to integrate G code and LUA to the extent you are talking about. Simply because G code can't really "communicate" with anything to that extent. Unless we also interpret LUA along side of G code with the same interpreter, then having what you describe is simply not possible. And then users would have to sprinkle LUA in with their G code just like you had to sprinkle VB in with your ladder logic. Terry... you have to distinguish what is a dream and what is reality.
In my example code above, it uses a semaphore like var to control the execution. Please explain to me how that will not work on different machines? Or for that matter, how would C/C++ mutexes and semaphores not work the same on different PCs? If that were the case, EVERY windows program would have to be custom made for EACH PC. That is not the case. I don't want to argue, but what you are saying is simply not the case and I feel it a disservice to the rest of the community to let such a notion stand.
There is nothing wrong. There is no design flaw. It is working as intended to make the system as flexible as it can be. It is the way it is for very good reasons. The sooner you accept that and just move on, the happier you will be.
Steve