Pause / Resume scripts

What is the problem?

Pause / resume scripts from Here

Scripts are working ok, however on resume the Z always ends up one layer higher than it should, meaning a dodgy layer extrusion and a weak point in the print.

What did you already try to solve it?

Tried to understand how the script works, but seems I'm too dense.

Have you tried running in safe mode?

Not relevant

Did running in safe mode solve the problem?

Not relevant

Systeminfo Bundle

Attached

WRITE HERE

Additional information about your setup

octoprint-systeminfo-20220113135914.zip (223.4 KB)