g-code to restore previous fan speed

Is there a g-code command working with Lulzbot printers, that is able to restore previous fan speed? It is needed for a tool change script to speed up tool changes with dual extruders.

Here and S3D example but would be useful for Cura as well:

M107 ; turn off fan
{IF NEWTOOL=0}M109 S[extruder0_temperature] T0; Set and wait for T0 extruder temperature
{IF NEWTOOL=1}M109 S[extruder1_temperature] T1; Set and wait for T0 extruder temperature
; Here gcode command to restore previous temperature without hardcoding it

Tried M106 R2 but that turns on to 100% fan speed, instead of the previous fan speed.

The M106 command should be what you need it will just need some additional coding along with it. I am not an expert with GCode by any means but this page might be helpful: http://marlinfw.org/docs/gcode/M106.html

It says that “M106 P T1 restores the previous fan speed.”

Thanks! I am guessing it is P0 but I will see when testing it.

Tried

M106 T1

Unfortunately did not work - it always seem to restore the print fan speed to 255.

S3D example snippet, where the slicer at tool change changes temperature on the extruders and fan, and run the tool change script:

[snip ...]
; layer 17, Z = 1.600
M104 S265 T0
M104 S160 T1
M106 S76
G1 X0 F4000 	; Tool change script Move to wait for temperatures
M107		; Tool change script Turn off fan to speed up extruder heating
M109 S265 T0	; Tool change script Set extruder temperature and wait
M106 T1		; Tool change script Restore previous fan speed
T0
; tool H0.200 W0.720
; ooze shield
[... snip]

The slicer change the dual extruder temperatures and set the fan speed just before running the tool change script. So in this case the fan should return to M106 S76, but instead “returns” to 100% seen in the TAZ6 display.