Hello Guest it is November 22, 2019, 07:12:17 AM

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

0 Members and 1 Guest are viewing this topic.

Offline smurph

*
  • *
  •  1,151 1,151
  • "That there... that's an RV."
    • View Profile
Re: Lua Lua Lua Louieeeeeee
« Reply #10 on: May 07, 2014, 07:08:45 PM »
Yep, that is why.  It is possible.  But you have to get crafty.  Both script environments have access to the Mach Registers.  So a register can be used to "communicate" between the two environments.  So in the M3 script, you set a register to something like "1" and in the PLC screen script, you watch that register.  If the register is "1" change the button label to one thing.  It is it "0", change the label to something else, etc...

Steve
Re: Lua Lua Lua Louieeeeeee
« Reply #11 on: May 07, 2014, 07:13:48 PM »
Might be easier to do it in the PLC Script and just look for a ledCW on or off

Offline smurph

*
  • *
  •  1,151 1,151
  • "That there... that's an RV."
    • View Profile
Re: Lua Lua Lua Louieeeeeee
« Reply #12 on: May 07, 2014, 07:16:45 PM »
Yes.  There is that!

Re: Lua Lua Lua Louieeeeeee
« Reply #13 on: May 07, 2014, 10:12:51 PM »
This code worked for me in the PLC Script to change the button labels.

I am interested in the ability to get and set values to the registers.
looked at it, but just caused Lua and Mach4 to crash several times just trying to get a value.

Code: [Select]
local SpinCW = scr.GetProperty('ledSpindleCW','Value','Value',0);
local SpinCCW = scr.GetProperty('ledSpindleCCW','Value','Value',0);

if (SpinCW == "1") then
    scr.SetProperty('btnSpindleCW', 'Label', 'SpindleCW OFF');
else
    scr.SetProperty('btnSpindleCW', 'Label', 'SpindleCW ON');
end
if (SpinCCW == "1") then
    scr.SetProperty('btnSpindleCCW', 'Label', 'SpindleCCW OFF');
else
    scr.SetProperty('btnSpindleCCW', 'Label', 'SpindleCCW ON');
end
Re: Lua Lua Lua Louieeeeeee
« Reply #14 on: May 08, 2014, 12:10:33 AM »
Crafty indeed !
The nifty possibilities continue, thanks for posting that Craig.

Russ
 :)