Hello Guest it is January 23, 2022, 09:38:17 AM

Author Topic: Lua Lua Lua Louieeeeeee  (Read 5287 times)

0 Members and 1 Guest are viewing this topic.

Lua Lua Lua Louieeeeeee
« on: May 06, 2014, 08:36:45 PM »
 Looking at various btn script examples, like this one:

    local inst = mc.mcGetInstance()
    mc.mcCntlMdiExecute(inst, 'G00 X0 Y0 Z0 A0')

How would you write it to do multiple lines of GCode with one finishing before the next one starts ? [[   ]]    /n   \n    ::)

One of several embarrassingly futile attempts: ::)
    local inst = mc.mcGetInstance()
    mc.mcCntlMdiExecute(inst, 'G00 Z2')
    mc.mcCntlMdiExecute(inst, 'G00 X0 Y0')

Hey, I'm just tinkering here, don't go out of your way now, this is not important.   :)
But, being you've already read it ............. ;D

Thanks again,
Russ
Re: Lua Lua Lua Louieeeeeee
« Reply #1 on: May 06, 2014, 11:19:55 PM »

Here is a snip of a tool changer so you can see how I formatted the strings
Code: [Select]
--Drop off the current tool
        local code = "G0 G53 Z0.0\n"
        code = code .. string.format("G0 G53 X%.4f Y%.4f\n", m_changePos[CurrentTool].x + m_X_Pullout, m_changePos[CurrentTool].y + m_Y_Pullout)
        code = code .. string.format("G0 G53 Z%.4f\n", m_ZtoolHeight)
        code = code .. string.format("G0 G53 X%.4f Y%.4f\n", m_changePos[CurrentTool].x, m_changePos[CurrentTool].y)
        mc.mcCntlGcodeExecute(inst, tostring(code))

        --Release tool
        mc.mcSignalSetState(unclamp, true);--Unclamp
        wx.wxSleep(.75)

        --Move to new tool
        code = string.format("G0 G53 Z%.4f\n", m_ZtoolHeight + m_PullupDist)
        code = code .. string.format("G0 G53 X%.4f Y%.4f", m_changePos[NewTool].x, m_changePos[NewTool].y)
        code = code .. string.format("G0 G53 Z%.4f", m_ZtoolHeight)
        mc.mcCntlGcodeExecute(inst, tostring(code))

        --Clamp tool
        mc.mcSignalSetState(unclamp, false);--Unclamp
        wx.wxSleep(.75)
        mc.mcToolSetCurrent(inst, NewTool)

        code = string.format("G0 G53 X%.4f Y%.4f", m_changePos[NewTool].x + m_X_Pullout, m_changePos[NewTool].y + m_Y_Pullout)
        code = code .. string.format("G0 G53 Z0.0")
        mc.mcCntlGcodeExecute(inst, tostring(code))


I am going to wait for the sun and look for dust...
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com
Re: Lua Lua Lua Louieeeeeee
« Reply #2 on: May 06, 2014, 11:57:36 PM »
Thanks for your time Brian  :)
I'll glean what I can out of that example. (almost looks like you found one of them scrolls too  ;D )

Supposed to be cloudy here tomorrow, so the dust shouldn't distract me.  ;D

See ya bud, thanks,
Russ
 :)
Re: Lua Lua Lua Louieeeeeee
« Reply #3 on: May 07, 2014, 09:28:47 AM »
With Brian's example, (and several references to the Rosetta Stone  ;D ), I came up with this:

--Go to Part Zero via Safe Z
    local inst = mc.mcGetInstance()
    local code = "G0 G53 Z0.0\n"
          code = code .. string.format("G0 X0 Y0\n")
          code = code .. string.format("G0 Z0.5\n")
          code = code .. string.format("G1 Z0 F10\n")
          mc.mcCntlGcodeExecute(inst, tostring(code))

It works as expected. I was pleasantly surprised.  :)

Added a button for a Safe Z type G28 also using the same format, a treat.  :)

Thanks Brian, Steve !
Russ
 :)

Offline Chaoticone

*
  • *
  •  5,626 5,626
  • Precision Chaos
    • View Profile
Re: Lua Lua Lua Louieeeeeee
« Reply #4 on: May 07, 2014, 10:53:53 AM »
 :)
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Lua Lua Lua Louieeeeeee
« Reply #5 on: May 07, 2014, 11:23:07 AM »
And so it is, One more example is the dead machine scrolls ... I will put them in a cave so no one can find them!
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com
Re: Lua Lua Lua Louieeeeeee
« Reply #6 on: May 07, 2014, 01:09:17 PM »
 ;D

Thanks again,
  :)

Offline BR549

*
  •  6,952 6,952
    • View Profile
Re: Lua Lua Lua Louieeeeeee
« Reply #7 on: May 07, 2014, 01:48:39 PM »
QUESTION, is mach4 using LUA or wxLUA or BOTH ??

(;-) TP

Offline smurph

*
  • *
  •  1,475 1,475
  • "That there... that's an RV."
    • View Profile
Re: Lua Lua Lua Louieeeeeee
« Reply #8 on: May 07, 2014, 06:53:20 PM »
wxLua. 

The hard part to get under one's hat is that there are two wxLua environments.  One in the GUI and one in the mcLua plugin.  The mcLua plugin is the one that runs all of the macros.  Putting the macro scripting in a plugin makes it possible for other script languages to be added later.  But I HIGHLY doubt that the GUI will ever run anything other than LUA.  So anyway, be aware that there are two separate scripting environments.  Both have access to the mc.* API.  But only the GUI has access to the scr.*  screen API.
Re: Lua Lua Lua Louieeeeeee
« Reply #9 on: May 07, 2014, 07:00:43 PM »
Is that why you can not change a button label from a m3 script?