I also could not find a signal to indicate a stopped state. However a possible fix is to add code to the stop button to set a register to indicate this - and read it in your code. Add similar to the start button to reset the register.
For ATC moves, it might make sense to use machine coordinates (G53) and to check at the start of the ATC cycle that the machine has been referenced. That way zero will always be in the same place!
Code to check if referenced: https://www.machsupport.com/forum/index.php?topic=36295.msg283262#msg283262
Hey, I forgot I asked this! Thanks for the reply.
I have actually found that 100% of my troubles where in the nesting of my Lua calls. Apparently Lua just sucks and the implementation embedded with Mach4 has some major issues. Case in point, same script but I assigned returned values to a variable and then make the next call and things like that and the scripts all work now.
I am not faulting the Mach people but Lua is the absolutely worst choice in scripting languages. As much as I hate Python I have to admit that it doesn't have troubles with foreign memory access and objects on the stack like Lua does.
So, for anyone following after this, my advice is never nest a function call inside of another, always assign a return value to a variable FIRST before passing it to the next function. Lua's concept of a "Stack" isn't just flawed, it is straight up broken. The return value may not be the thing your were expecting at that point in time because the execution engine hasn't yet made that object available. The only way to guarantee that thing is what you think it is is to assign it to a variable FIRST.
Then Lua is like, "Oooh, you really care what this thing is. Ok, it is here now."
That signal I was looking for never showed up because the object I was passed was empty or never connected to the backend with the data :p
Once I assigned it to a variable, then passed it to the next function, there was my signal!
I can get mad at people and scream and yell, or I can just get my Teknic ClearCore out and never have these issues again
![Wink ;)](https://www.machsupport.com/forum/Smileys/default/wink.gif)