331
Mach4 General Discussion / Re: Understanding Lua
« on: December 19, 2016, 05:13:55 PM »
Change the filename to load_modules.mcs
DazTheGas
DazTheGas
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
local profile = mc.mcProfileGetName(inst)
local path = mc.mcCntlGetMachDir(inst)
package.path = path .. "\\Profiles\\" .. profile .. "\\Modules\\?.lua;" .. path .. "\\Modules\\?.lua;"
function GoToWorkZero()
mc.mcCntlMdiExecute(inst, "G00 X0 Y0 A0")--Without Z moves
--mc.mcCntlMdiExecute(inst, "G00 G53 Z0\nG00 X0 Y0 A0\nG00 Z0")--With Z moves
end
local inst = mc.mcGetInstance()
function CheckHomeState()
local en_axis = 0
repeat
local Is_Enabled = mc.mcAxisIsEnabled(inst, en_axis)
if Is_Enabled == 1 then
local is_Homed = mc.mcAxisIsHomed(inst, en_axis)
if is_Homed ~= 1 then
HomeDialog()
return
end
end
en_axis = en_axis + 1
until( en_axis == 6 )
mc.mcCntlEnable(inst, 1)
end
function HomeDialog()
local h_dialog = wx.wxMessageDialog(wx.NULL,"Clicking Ok will Home all Axis, Cancel will abort", "Warning Machine Not Homed",wx.wxOK + wx.wxCANCEL)
local test = h_dialog:ShowModal()
if test == wx.wxID_OK then
mc.mcCntlEnable(inst, 1)
wait = coroutine.create (RefAllHome)
else
scr.SetProperty('tbutton2','Button State','Up')
return
end
end
CheckHomeState()