Hello Guest it is April 19, 2024, 02:20:28 PM

Author Topic: need some lua help  (Read 9301 times)

0 Members and 1 Guest are viewing this topic.

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: need some lua help
« Reply #20 on: May 07, 2015, 12:17:20 AM »
do i need to put in a address for this
unction m1005()   
   --local macroname = "m1005"
   function GetRegister(regname)
      local rc;
      local inst = mc.mcGetInstance();
      local hreg = mc.mcRegGetHandle(inst, string.format("iRegs0/%s", regname));
      return mc.mcRegGetValueString(hreg);
   end
   local TS_XPosVal = tostring(GetRegister("TS_XPos"));
   local YPosVal = tostring(GetRegister("TS_YPos"));
   local TypeVal = tostring(GetRegister("TS_Type"));
   local TouchPosVal = tostring(GetRegister("TS_TouchPos"));
   local ProbeHVal = tostring(GetRegister("TS_ProbeH"));
   local RetractLVal = tostring(GetRegister("TS_RetractL"));
   local DefaultVal = tostring(GetRegister("TS_DefaultL"));
   --regval = GetRegister("TS_Type");
   --wx.wxMessageBox(regval);
end

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

so the tool height probing macro can find it what is m1005 from the manual

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: need some lua help
« Reply #21 on: May 07, 2015, 03:54:38 AM »
I have played some more I add this into the Auto Tool Setting Macro from the manual

function GetRegister(regname)
      local rc;
      local inst = mc.mcGetInstance();
      local hreg = mc.mcRegGetHandle(inst, string.format("iRegs0/%s", regname));
      return mc.mcRegGetValueString(hreg);
   end

now the Get touch off parameters work but when it gets to the Check Probe part it fails it comes up with this
[string "C:\Mach4Hobby\Macros\m1005.mcs"]:48: wxLua: Expected a 'number' for parameter 2, but got a 'nil'.
Function called: 'mcSignalGetHandle(number, nil)'
01. mcSignalGetHandle(number, number, lightuserdata)
stack traceback:
   [C]: in function 'mcSignalGetHandle'
   [string "C:\Mach4Hobby\Macros\m1005.mcs"]:48: in function 'm1005'
   [string "C:\Mach4Hobby\Macros\m1005.mcs"]:109: in main chunk

I am running it in sim I have defind a probe input

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: need some lua help
« Reply #22 on: May 07, 2015, 07:45:49 AM »
Function called: 'mcSignalGetHandle(number, nil)'--is your error
the "nil" is the parameter 2, you need to have something like:   mc.ISIG_INPUT1 in there.

Scott
fun times

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: need some lua help
« Reply #23 on: May 07, 2015, 03:27:25 PM »
I think they did this with bits missing so people will learn a thing or two more than just copy and past code to its correct spot it`s not fun but I know how it was for you and ya bro to do now.

thanks for the help scott

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: need some lua help
« Reply #24 on: May 08, 2015, 03:10:56 AM »
thank you very much Scott I I think i got it working your hints are very good now to the next one
« Last Edit: May 08, 2015, 03:12:27 AM by daniellyall »