@Chriss - I'm also one of those people that wants to know how things work in detail and ended up writing my own macros for tool changing on the printer we are building at our maker space. Our tool changer is a modification of the Jubilee tool changer, which was a modification of the ESD tool changer. Here are some concepts we learned along the way - meaning things I got wrong at least once before getting it right.
X and Y Tool offsets
We designated tool0 to have X and Y offsets of 0. Why not? it makes stuff easier when setting up the other tools.
We designed a two-color part that we print to help us dial in the offsets. Its two concentric square, like two square donuts nested together. Here are the stl files.
XY_nozzle alignment inner ring.stl XY_nozzle alignment outer ring.stl If the X offsets are perfect, the total with of the right and left sides of the "donut" should be equal if they aren't equal, the different is twice the amount the offset needs to be changed. Same with the Y direction. We eyeball the alignment the first time, then use calipers to get the final adjustment.
Z offsets
Each tool needs to have it's Zoffset set independently. We didn't designate roo0 to be the origin because we make Z offset changes often.
We use baby steps to make final adjustments to the Z offset and we wrote a macro that will read the current baby steps and z-offset form the object model, and change the z-offset to "roll in" the baby steps if baby steps have been set. We run this macro whenever we park a tool (ie run tfreeN.g).
Moving outside soft limits
We set the X and Y soft limits of the machine so that prints can't drive the printhead into the tool docking area. This menas that when we dock or undock a tool, we need to allow moves outside the limits (M564 S0). When we move back inside the limits after we pick up a new tool, we need to disallow moves outside the limits (M564 S1). Be sure to put and M400 (wait for moves to finish) before the M564 S1 or RRF may discover you are outside limits. We crashed the tool several times while learning this one.
tpre vs tpost
This one confused us for a while until we understood that the "event" that the "pre" and "post" refer to is the changin of the tool number in RRF. This means that during a tool change RRF has no "awareness" the tool offsets, extruder settings, etc while it is running tpreN.g. If you have any gcode command in tpreN that has a parameter for "current tool", "current heater", "current extruder", "current filament", etc, they probably should be in the tpostN.g file.
simplifying the macros
All three of our tools have the same docking procedure, with only the X location of the dock different. We ended up writing a single macro for each of tfree, tpre and tpost, using an input parameter for the X location of the dock. We called these macros tfree_all.g, tpre_all.g, and tpost_all.g. In the actual tpostN.g file, we just use an M98 to call our macro. With this setup, we can tweak the parking macros in one place.
The slicer
We normally use PrusaSlicer and have one line of custom gcode for each tool. This line sets the standby temperature for the tool, based on the nozzle temperature set in the slicer. We did this to try to minimize the time a tool takes to re-heat after it's been picked up. We started with 25*C below active temperature, but this was giving us about 30sec of wait time per tool change and it felt like forever. When we kept the nozzle temperature at the active temperature we had some problems with the plastic melting beyond the cold-break when the tool was docked for a long time.
PanelDue
In PrusaSlicer, the extruder numbering is "1-based" - and RRF it's "0-based". this leads to confusion for users when they are using the slicer. We can change the labeling for the tools in DWC to align with the Slicer numbering. Our main user interface is the PanelDue and we have not found a way to change the tool numbering on it.