OK, good.
Yup, running dwell in Gcode is as good a way as any. I would just use a single line or edit Katz function to take a time parameter if it was something i might use in different places.
The code below should also check the type of dwell and convert to a number or error out if it can't be converted.
function wait(dwell)
local inst = mc.mcGetInstance()
local defaultDwell = 250
if (dwell == nil) or (dwell < defaultDwell) then --No dwell passed or a shorter dwell than the motion device can process will cause errors
dwell = defaultDwell
end
local GCode = string.format("G4 p" .. tostring(dwell))
rc = mc.mcCntlGcodeExecuteWait (inst, GCode) ---wait for time of dwell
--Do something here if rc ~= 0 because you have an error
end
--Then use it like this
wait(100) --will wait for 250 milliseconds == .25 seconds because it is less than default defined in function
wait() --will wait for 250 milliseconds == .25 seconds because dwell is not defined so function will define as default
wait(500) --will wait for 500 milliseconds == .5 seconds
Don't use it like this though..........
wait("10 seconds") --will cause problems if the dwell type check I mentioned above isn't added