Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: litronics on March 04, 2018, 08:33:13 AM

Title: Signal Script - struggling to get it working
Post by: litronics on March 04, 2018, 08:33:13 AM
Hi all,
I just started to get my head arround the LUA stuff and trying to get a simple singnal scirpt working.

As a simple starting point I wanted to use my Probe to actually trigger the status of an general output.
I have added a few lines of code in my SigLib in the Screen Load script:

Code: [Select]
[mc.ISIG_PROBE] = function (state)
    inst = mc.mcGetInstance()
    local out1handle = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1)
    local out1state = mc.mcSignalGetState(out1handle)
    if (state == 1) then     
        mc.mcSignalSetState(out1state, true)
    else
        mc.mcSignalSetState(out1state, false)
    end
end,

As far as I understand it should act on my Probe as input.
Get the handle and state for desired output and set it accordingly.

However - this doesn't actually work.

What am I doing wrong here??
Title: Re: Signal Script - struggling to get it working
Post by: Fledermaus on March 04, 2018, 04:53:33 PM
Try this (I haven't tested it):

    local out1handle = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1)
    mc.mcSignalSetState(out1handle , state)

In C, the state is true/false, but in LUA it is 0/1.

Allan
 
Title: Re: Signal Script - struggling to get it working
Post by: litronics on March 08, 2018, 02:54:03 AM
Thanks Allan!

tose two lines are working :)