Simple Machines Community Forum

General Community => Scripting Help => Topic started by: fishnorling on December 18, 2020, 07:50:21 AM

Title: Rookie LUA question
Post by: fishnorling 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
Title: Re: Rookie LUA question
Post by: Kindred 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?)
Title: Re: Rookie LUA question
Post by: Shambles 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/
Title: Re: Rookie LUA question
Post by: Herman's Mixen on December 18, 2020, 02:53:16 PM
looks like hes up to some audio stuff programming wich are used generally in vst plugins ;)
Title: Re: Rookie LUA question
Post by: Shambles on December 18, 2020, 03:18:24 PM
Quote from: Herman's Mixen on December 18, 2020, 02:53:16 PM
looks like hes up to some audio stuff programming ...

Hmmmm.....  doubt

Quote from: fishnorling on December 18, 2020, 07:50:21 AM
... open a pneumatic valve ...
Title: Re: Rookie LUA question
Post by: live627 on December 19, 2020, 05:28:23 AM
QuoteHmmmm.....  doubt
press X?