Previous tool after T command
-
After a T command, is there a way to get the number of the tool which was active right before the T command? The object model state.previousTool doesn't quite do that.
If the T command doesn't actually change the active tool, it will give you the tool from that last time a T command did. For example:
T0 T1 echo state.previousTool ; prints 0 T1 echo state.previousTool ; also prints 0
The second T1 won't trigger tpre1.g or tpost1.g to run, either. If you're interested in reacting to tool temperature changes in the prior tool after the T1 command, but only if the active tool actually was different before the T command, you need to see whether the tool actually changed or not. But the T1 may activate a tool and cause it to heat even if it's not actually changing the active tool.
Putting state.currentTool into a variable before the T1 command works in some cases, but it's awkward in others. For instance, if you need to react to this in a macro called by daemon.g, you'd probably have to do something complicated with global variables. So I'm looking for a hypothetical "state,preTTool".
But I can't think of any way to get the "real" previous tool number besides putting state.currentTool into a variable before the T1. Maybe that's the only way, but I thought I'd ask.