General Community > Scripting Help

Rookie LUA question

(1/2) > >>

fishnorling:
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

Kindred:
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?)

Shambles:
^ yep.

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

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

Herman's Mixen:
looks like hes up to some audio stuff programming wich are used generally in vst plugins ;)

Shambles:

--- Quote from: Herman's Mixen on December 18, 2020, 02:53:16 PM ---looks like hes up to some audio stuff programming ...

--- End quote ---

Hmmmm.....  doubt


--- Quote from: fishnorling on December 18, 2020, 07:50:21 AM ---... open a pneumatic valve ...

--- End quote ---

Navigation

[0] Message Index

[#] Next page

Go to full version