Hello Guest it is March 28, 2024, 04:42:25 PM

Author Topic: converting Macro to Lua language  (Read 1792 times)

0 Members and 1 Guest are viewing this topic.

converting Macro to Lua language
« on: July 09, 2015, 09:47:45 AM »
Hello

I am working on converting one of my workstations from Mach3 to Mach4. Having trouble understanding the Lua scripting. Could someone take a look at this simple Macro and help convert it to Lua.

Thanks
Josh

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: converting Macro to Lua language
« Reply #1 on: July 09, 2015, 11:17:49 AM »
Try this:

Code: [Select]
function m1002()
    local mInst         = 0;
    local inst          = mc.mcGetInstance(mInst);
    local NumValue      = 0;
    local hSig          = 0;
    local rc            = 0;
    local StringValue   = "";
    local state         = 0;

    --There is no rc error checking in this....
    hSig, rc = mc.mcSignalGetHandle(inst,mc.ISIG_INPUT2);
    state, rc = mc.mcSignalGetState(hSig);

    if (state == 0) then --0 is Input2 NOT active, 1 is Active
        --send error message to Machs error message box
        mc.mcCntlSetLastError(inst, "CHECK ENERGY MONITOR!!");

        --Optional send error message to a wx Message box
        --wx.wxMessageBox("CHECK ENERGY MONITOR!!");
    end
   
    local StopDebugVar = 0;
end

if (mc.mcInEditor() == 1) then
    m1002();
end

--have fun!
--Scott
fun times
Re: converting Macro to Lua language
« Reply #2 on: July 09, 2015, 03:46:14 PM »


I don't think i'm saving it properly. I have it saved in the profile i'm using under macros.

I also tried running one of the codes in the Luaexamples file with no luck.

Thanks for the help Scott!