Advertisement:

Author Topic: Rookie LUA question  (Read 415 times)

Offline fishnorling

  • Newbie
  • *
  • Posts: 1
Rookie LUA question
« on: December 18, 2020, 07:50:21 AM »
Good morning, brand newbie, first attempt at editing LUA for Mach 4.  I want to trigger a signal, open a pneumatic valve, delay, then turn off.  I have been able to find examples and come up with the following code.  I have tried to run in the edit/debugger, and the best I can get for a result is nil, however with that said, the best I can get for known code that does run is, nil.  So, stumped.  I am wondering if anyone out there is willing to comment on this code;

function m102 ()
   local inst = mc.mcGetInstance() --Get the instance of Mach4
local IOName = mc.OSIG_OUTPUT1 --Save the name of the Signal (as stored inside of Mach4)
local ActivateSignalTime = 5000 --Time in milliseconds that we want the signal to be active.
local hReg = 0 --The handle to the signal
local rc = 0

hSig, rc = mc.mcSignalGetHandle(inst, IOName)
if (rc ~= 0) then --There was error   
   mc.mcCntlSetLastError(inst, "There was an error")
else
   rc = mc.mcSignalSetState(hSig, 1) --Turn the output on
   if (rc ~= 0) then --There was error   
      mc.mcCntlSetLastError(inst, "There was an error")
   else
      wx.wxMilliSleep(ActivateSignalTime) --Sleep for the commanded time (so that the output stays on as long as we want).
      rc = mc.mcSignalSetState(hSig, 0) --Turn the output off
      if (rc ~= 0) then --There was error   
         mc.mcCntlSetLastError(inst, "There was an error")
      end
   end
end


Thanks
Dave

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 60,073
  • Gender: Male
    • Kindred-999 on GitHub
Re: Rookie LUA question
« Reply #1 on: December 18, 2020, 09:01:35 AM »
I think that you are on the wrong site.  This is a support site for Simple Machines Forum software...   it sounds like you want to be on some other site (perhaps one that is using our software?)
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,588
  • Gender: Male
    • i30 Owners Club
Re: Rookie LUA question
« Reply #2 on: December 18, 2020, 02:42:33 PM »
^ yep.

Here's where you need to be (although you are already a contributing member there anyway  ::))

https://www.machsupport.com/forum/

Offline Herman's Mixen

  • SMF Hero
  • ******
  • Posts: 7,304
    • HermanMixen on Facebook
    • @Hermans_Mixen on Twitter
    • Herman's Mixen
Re: Rookie LUA question
« Reply #3 on: December 18, 2020, 02:53:16 PM »
looks like hes up to some audio stuff programming wich are used generally in vst plugins ;)
Met vriendelijke groet, The Burglar!

 House Mixes | Mixcloud | Any Intelligent fool can make things bigger, more complex, and more violent.
It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Albert Einstein

Former Godfather of our dutch community ;)

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,588
  • Gender: Male
    • i30 Owners Club
Re: Rookie LUA question
« Reply #4 on: December 18, 2020, 03:18:24 PM »
looks like hes up to some audio stuff programming ...

Hmmmm.....  doubt

... open a pneumatic valve ...

Offline live627

  • Developer
  • SMF Hero
  • *
  • Posts: 5,869
  • Gender: Male
    • live627 on Facebook
    • live627 on GitHub
    • live627 on LinkedIn
    • @live627 on Twitter
    • livemods
Re: Rookie LUA question
« Reply #5 on: December 19, 2020, 05:28:23 AM »
Quote
Hmmmm.....  doubt
press X?