Hello Guest it is April 24, 2024, 08:42:45 PM

Author Topic: mcX360 Plugin for Lua  (Read 45446 times)

0 Members and 1 Guest are viewing this topic.

Re: mcX360 Plugin for Lua
« Reply #70 on: August 10, 2018, 10:01:39 AM »
another dumb question
where does the code actually get stored, file location. i know i can do a save as and put a copy were i want for safe keeping
but when i create a pannel and add code were is that kept

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: mcX360 Plugin for Lua
« Reply #71 on: August 10, 2018, 02:57:58 PM »
The code is embed into your screenset and is only editable through the screen editor.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: mcX360 Plugin for Lua
« Reply #72 on: August 14, 2018, 03:43:29 PM »
is there a  way to check the status of a button on the Mach 4 form  ie the Enable/Disable button
i am using the A button on the Xbox controller to toggle the Enable/Disable button but had to resort to a flag (local ToggleState) to see if it has been enabled  by my code
only problem with doing it this way is it assumes that it is in the disabled state to start off


using
mc.mcCntEnable(mIst, 1) to go from disable to enable
and
mc.mcCntEnable(mIst, 0) to go from enabled to disable
it would be nice to test the current state first before setting it to another state
Re: mcX360 Plugin for Lua
« Reply #73 on: August 14, 2018, 06:05:04 PM »
Figured this one out also.  :)

what is the best way to do a Velocity move in X, Y, and Z axis
currently i am using

mc.mcVelocityStart(mInst, Axis, direction)

but speed is from the Slider on the Mach4 panel and the Jog DRO

So i have to keep changing those values as RTHY and RTHX values change from 0-90 (i have a dead spot -30 to +30
while this works it is messy
is there a better way to do a velocity move

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: mcX360 Plugin for Lua
« Reply #74 on: August 16, 2018, 07:29:03 AM »
Quote
is there a  way to check the status of a button on the Mach 4 form  ie the Enable/Disable button

There are some good examples in the Screen Load Script of the stock wx4 screenset, take a look at the Spindle functions.

I use

Code: [Select]
-- Start Button
if GetXin("Btn_START") == 1 and Start_Btn == false then
        local mcCntlEnable = mc.mcSignalGetState (mc.mcSignalGetHandle (mInst, mc.OSIG_MACHINE_ENABLED))
        if mcCntlEnable == 1 then
            mc.mcCntlEnable(mInst, 0)
        else
            mc.mcCntlEnable(mInst, 1)
        end
Start_Btn = true
    end
    if GetXin("Btn_START") == 0 and Start_Btn == true then
--Release Command if any
Start_Btn = false
    end

Quote
what is the best way to do a Velocity move in X, Y, and Z axis
To set the velocity you just need to take a value from the thumbstic and set mc.mcJogSetRate as a percentage so the further you push the stick the faster it moves.

DazTheGas
New For 2022 - Instagram: dazthegas

Offline mhd

*
  •  11 11
    • View Profile
Re: mcX360 Plugin for Lua
« Reply #75 on: September 19, 2018, 03:28:04 PM »
This was made for an XBox controller only.

DazTheGas

First of all, thank you for the good video
You say that the lua you but it only for XBox 360 but I hook my the PS3 controller and check the Register Diagnostics /mcX360_LAU and it gives me a value!!

The problem in my case that when I try to code the software help me with the function. because I'm not that good in coding and I'm learning from your video.

Like when I type (Local or mc.mcRegGetHandle) it the software help me find them

but in case of (mc.mcGetInstance(), Start) there is NO option to select from.


Did I do something wrong?


Best regard
shrooqi

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: mcX360 Plugin for Lua
« Reply #76 on: September 19, 2018, 04:52:24 PM »
It would be easier to post what code you are using.

DazTheGas
New For 2022 - Instagram: dazthegas

Offline mhd

*
  •  11 11
    • View Profile
Re: mcX360 Plugin for Lua
« Reply #77 on: September 20, 2018, 05:31:35 AM »
as I motion that the Register Diagnostics /mcX360_LUA give me a value when I press any bottom

I follow your video step by step and this is the code


 ------- Declaer local---------------
local mInst = mc.mcGetInstance()
local Xenable= 0

-------------- Ps3 Init Panel------------

Ps3_Penal = wx.wxPanel( wx.NULL , wx.wxID_ANY , wx.wxDefaultPosition , wx.wxDefaultSize)
Ps3_Timer = wx.wxTimer (Ps3_Penal)
Ps3_Timer : Start(100)

----------- Function----------------

function GetXin(Xinput)
   local hreg = mc.mcRegGetHandle(mInst , string.format("mcX360_LUA/%s") , Xinput)
   return mc.mcRegGetHandle(hreg)
end

------------Event Timers-------------
Ps3_Penal : Connect (wx.wxEVT_TIMER , function(event)
      
      if GetXin("LTR_Val") > 150 and Xenable == 0 then
         Xenable = 1
         mc.mcCntlSetLastError(mInst , "Ps3 Running")
         
      elseif GetXin ("LTR_Val") < 50 and Xenable == 1 then
         Xenable =0
         mc.mcCntlSetLastError(mInst , "Ps3 Stopped")
         
      end   
      
      
   end   )

Offline mhd

*
  •  11 11
    • View Profile
Re: mcX360 Plugin for Lua
« Reply #78 on: September 22, 2018, 02:37:40 PM »
It would be easier to post what code you are using.

DazTheGas



Posts: 7


   

Re: mcX360 Plugin for Lua
« Reply #77 on: September 20, 2018, 04:31:35 AM »
 

as I motion that the Register Diagnostics /mcX360_LUA give me a value when I press any bottom

I follow your video step by step and this is the code


 ------- Declaer local---------------
local mInst = mc.mcGetInstance()
local Xenable= 0

-------------- Ps3 Init Panel------------

Ps3_Penal = wx.wxPanel( wx.NULL , wx.wxID_ANY , wx.wxDefaultPosition , wx.wxDefaultSize)
Ps3_Timer = wx.wxTimer (Ps3_Penal)
Ps3_Timer : Start(100)

----------- Function----------------

function GetXin(Xinput)
   local hreg = mc.mcRegGetHandle(mInst , string.format("mcX360_LUA/%s") , Xinput)
   return mc.mcRegGetHandle(hreg)
end

------------Event Timers-------------
Ps3_Penal : Connect (wx.wxEVT_TIMER , function(event)
     
      if GetXin("LTR_Val") > 150 and Xenable == 0 then
         Xenable = 1
         mc.mcCntlSetLastError(mInst , "Ps3 Running")
         
      elseif GetXin ("LTR_Val") < 50 and Xenable == 1 then
         Xenable =0
         mc.mcCntlSetLastError(mInst , "Ps3 Stopped")
         
      end   
     
     
   end   )

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: mcX360 Plugin for Lua
« Reply #79 on: September 25, 2018, 09:28:12 AM »
Your GetXin function is incorrect

your code
Code: [Select]
function GetXin(Xinput)
   local hreg = mc.mcRegGetHandle(mInst , string.format("mcX360_LUA/%s") , Xinput)
   return mc.mcRegGetHandle(hreg) -- This line is wrong
end

code should be
Code: [Select]
function GetXin(xinput)
local hreg = mc.mcRegGetHandle(inst, string.format("mcX360_LUA/%s", xinput))
return mc.mcRegGetValue(hreg) -- or return mc.mcRegGetValueLong(hreg)
end

DazTheGas
New For 2022 - Instagram: dazthegas