Hello Guest it is April 27, 2024, 09:43:41 AM

Author Topic: Screen script to module function for button  (Read 535 times)

0 Members and 1 Guest are viewing this topic.

Offline DAAD

*
  •  103 103
    • View Profile
Screen script to module function for button
« on: April 15, 2020, 03:39:03 AM »
I have the following code in the screen script that i want to add to the module i'm writing.
This way all my custom functions are in one place.
So if i have ever to do a rebuild of mach 4 all i have to do is to call  the functions in the buttons wanted.

For some reason i can't get the following 2 functions working:

Goto Zero (adapted screen script to module)
Code: [Select]
function GoToWorkZero() -- Screen script code
local inst = mc.mcGetInstance("GoToWorkZero()")
local val = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_3)
local msg = "G0 G53 Z-20 A-20\n G90 X0 Y0\nG" .. val
mc.mcCntlMdiExecute(inst, msg)

end

Code: [Select]
---------------Goto Work Zero module button -----------------------------------------------------------------
function zControl.GoToZero()
local val = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_3)
local msg = "G0 G53 Z-20 A-20\n G90 X0 Y0\nG" .. val
mc.mcCntlGcodeExecute(inst, msg)
mc.mcCntlSetLastError(inst, "GoTO Work Zero")
end


Park position (works directly in a button)

Code: [Select]
---------------Park position button-----------------------------------------------------------------------
function zControl.Park()
mc.mcCntlSetLastError(inst, "GoTo park position")
mc.mcCntlGcodeExecute(inst, "G00 G53 Z-20 A-20\n G53 X3100 Y1200")
end


Keep Safe!

Adam