Here you are Chad... it is not code that will change the world or anything but it should give you what you need as a base to start from. The cool part is that it shows you how you can read data from the line of the Mcode! The only thing I could not do for you is set the max Hz or set the register that would set the value.
Please tell me if this works for you .. 
function m8(hParam) --The param is a P value called from Gcode. M8P50 for example would be 50%, No value will be 100%.
	local inst = mc.mcGetInstance()
	local varP = 100.00 -- default is 100%
	if (hParam ~= nil) then
		local flagP, rc = mc.mcCntlGetLocalVarFlag(inst, hParam, mc.SV_P)
		if (flagP == 1) then --Check that the flag has been set so we do not get an unexpected value for mc.SV_P
			varP = mc.mcCntlGetLocalVar(inst, hParam, mc.SV_P)
		end
	end
	mc.mcCntlSetLastError(inst, string.format("P val == %.0f",varP))
	local handle = 0;
	handle = mc.mcRegGetHandle(inst,"0Regs0/test")-- TODO  !!!!!!!!!!!!!!! Set Modbus register value here
	if (handle ~= 0)then
		local MaxVFDSpeed = 7000
		local val =  MaxVFDSpeed*varP/100 
		val = string.format("%.0f",tonumber(val))-- Get Val as an int
		mc.mcRegSetValue(regH ,tonumber(val))-- Set the speed of the pump
	end
	handle = 0;
	handle = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON)
	if (handle ~= 0)then
		mc.mcSignalSetState(handle, 1)
	end
end
if (mc.mcInEditor() == 1) then
    m8()
end